add_relationship, relationship_info, relationships moved to ResultSource
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Componentised.pm
CommitLineData
227d4dee 1package DBIx::Class::Componentised;
2
147dd158 3use Class::C3;
4
227d4dee 5sub inject_base {
6 my ($class, $target, @to_inject) = @_;
7 {
8 no strict 'refs';
e4c24739 9 unshift(@{"${target}::ISA"}, grep { $target ne $_ && !$target->isa($_)} @to_inject);
227d4dee 10 }
9a15732e 11 my $table = { Class::C3::_dump_MRO_table };
75a23b3e 12 eval "package $target; import Class::C3;" unless exists $table->{$target};
9a15732e 13 Class::C3::reinitialize() if defined $table->{$target};
227d4dee 14}
15
16sub load_components {
17 my $class = shift;
7411204b 18 my $base = $class->component_base_class;
19 my @comp = map { "${base}::$_" } grep { $_ !~ /^#/ } @_;
227d4dee 20 $class->_load_components(@comp);
21}
22
23sub load_own_components {
24 my $class = shift;
25 my @comp = map { "${class}::$_" } grep { $_ !~ /^#/ } @_;
26 $class->_load_components(@comp);
27}
28
29sub _load_components {
30 my ($class, @comp) = @_;
31 foreach my $comp (@comp) {
32 eval "use $comp";
33 die $@ if $@;
34 }
35 $class->inject_base($class => @comp);
36}
37
381;