license => 'perl',
module_name => 'DBIx::Class',
requires => {
- 'DBI' => 0,
- 'NEXT' => 0,
- 'SQL::Abstract' => 1.19,
- 'DBD::SQLite' => 1.08,
- 'Tie::IxHash' => 0,
+ 'DBI' => 0,
+ 'UNIVERSAL::require' => 0,
+ 'NEXT' => 0,
+ 'SQL::Abstract' => 1.19,
+ 'DBD::SQLite' => 1.08,
+ 'Tie::IxHash' => 0,
},
create_makefile_pl => 'passthrough',
create_readme => 1,
use warnings;
use vars qw($VERSION);
-use base;
-
-$VERSION = '0.01';
-
-sub load_components {
- my $class = shift;
- my @comp = map { "DBIx::Class::$_" } grep { $_ !~ /^#/ } @_;
- $class->_load_components(@comp);
-}
-
-sub load_own_components {
- my $class = shift;
- my @comp = map { "${class}::$_" } grep { $_ !~ /^#/ } @_;
- $class->_load_components(@comp);
-}
-
-sub _load_components {
- my ($class, @comp) = @_;
- foreach my $comp (@comp) {
- eval "use $comp";
- die $@ if $@;
- }
- no strict 'refs';
- unshift(@{"${class}::ISA"}, @comp);
-}
+use base qw/DBIx::Class::Componentised/;
+
+$VERSION = '0.02';
+
1;
--- /dev/null
+package DBIx::Class::Componentised;
+
+sub inject_base {
+ my ($class, $target, @to_inject) = @_;
+ {
+ no strict 'refs';
+ unshift(@{"${target}::ISA"}, grep { $target ne $_ } @to_inject);
+ }
+}
+
+sub load_components {
+ my $class = shift;
+ my @comp = map { "DBIx::Class::$_" } grep { $_ !~ /^#/ } @_;
+ $class->_load_components(@comp);
+}
+
+sub load_own_components {
+ my $class = shift;
+ my @comp = map { "${class}::$_" } grep { $_ !~ /^#/ } @_;
+ $class->_load_components(@comp);
+}
+
+sub _load_components {
+ my ($class, @comp) = @_;
+ foreach my $comp (@comp) {
+ eval "use $comp";
+ die $@ if $@;
+ }
+ $class->inject_base($class => @comp);
+}
+
+1;
use base qw/Class::Data::Inheritable/;
use base qw/DBIx::Class/;
-__PACKAGE__->load_components(qw/Exception/);
+__PACKAGE__->load_components(qw/Exception Componentised/);
__PACKAGE__->mk_classdata('class_registrations' => {});
=head1 NAME
while (my ($comp, $comp_class) = each %reg) {
my $target_class = "${target}::${comp}";
$class->inject_base($target_class, $conn_class, $comp_class);
+ $target_class->table($comp_class->table);
@map{$comp, $comp_class} = ($target_class, $target_class);
}
{
$target->connection(@info);
}
-sub inject_base {
- my ($class, $target, @to_inject) = @_;
- {
- no strict 'refs';
- unshift(@{"${target}::ISA"}, grep { $target ne $_ } @to_inject);
- }
-}
-
1;
=back
use Test::More;
-plan tests => 22;
+plan tests => 23;
use lib qw(t/lib);
$new->position(5);
$new->insert_or_update;
is( DBICTest::Track->find(100)->position, 5, 'insert_or_update update ok');
+
+eval { DBICTest::Track->load_components('DoesNotExist'); };
+
+ok $@, $@;
use strict;
use warnings;
use DBICTest::Schema;
-use DateTime;
my $db_file = "t/var/DBIxClass.db";