下記スクリプト、今思ったけど Catalyst App の Model を外部から使うときも便利かも。

use FindBin;
use lib "$FindBin::Bin/../lib";

use DBIx::Class::Loader::Pluggable;

DBIx::Class::Loader::Pluggable->new(
    dsn => 'dbi:...',
    namespace => 'MyApp::Model::DBIC',
);

とかでテーブルクラスもロードしてくれる。

by typester / at 2006-01-24T23:05:00 / life / Comment

下書き

package DBIx::Class::Loader::Pluggable; use strict;

use base qw/DBIx::Class::Loader/;
require Module::Pluggable::Fast;

sub new {
    my $class = shift;
    my %attr  = @_;

    my $self = $class->SUPER::new(@_);

    Module::Pluggable::Fast->import(
        name    => '_components',
        require => 1,
        search  => [ $attr{namespace} ],
    );
    __PACKAGE__->_components;

    $self;
}

1;
by typester / at 2006-01-24T19:59:00 / perl / Comment

出社。

by typester / at 2006-01-24T11:17:00 / life / Comment