Commit | Line | Data |
75d07914 |
1 | package # hide from PAUSE |
c0e7b4e5 |
2 | DBIx::Class::Componentised; |
227d4dee |
3 | |
bf5ecff9 |
4 | use strict; |
5 | use warnings; |
6 | |
1680d317 |
7 | use base 'Class::C3::Componentised'; |
aaba9524 |
8 | use Carp::Clan qw/^DBIx::Class/; |
147dd158 |
9 | |
227d4dee |
10 | sub inject_base { |
11 | my ($class, $target, @to_inject) = @_; |
12 | { |
13 | no strict 'refs'; |
eb47985e |
14 | foreach my $to (reverse @to_inject) { |
df88a29c |
15 | my @comps = qw(DigestColumns ResultSetManager Ordered UTF8Columns); |
16 | # Add components here that need to be loaded before Core |
17 | foreach my $first_comp (@comps) { |
18 | if ($to eq 'DBIx::Class::Core' && |
19 | $target->isa("DBIx::Class::${first_comp}")) { |
20 | warn "Possible incorrect order of components in ". |
21 | "${target}::load_components($first_comp) call: Core loaded ". |
22 | "before $first_comp. See the documentation for ". |
23 | "DBIx::Class::$first_comp for more information"; |
24 | } |
25 | } |
26 | unshift( @{"${target}::ISA"}, $to ) |
27 | unless ($target eq $to || $target->isa($to)); |
eb47985e |
28 | } |
227d4dee |
29 | } |
20518cb4 |
30 | |
1680d317 |
31 | $class->next::method($target, @to_inject); |
efe6365b |
32 | } |
33 | |
34 | # Returns a true value if the specified class is installed and loaded |
35 | # successfully, throws an exception if the class is found but not loaded |
36 | # successfully, and false if the class is not installed |
37 | sub load_optional_class { |
38 | my ($class, $f_class) = @_; |
7dd382fb |
39 | eval { $class->ensure_class_loaded($f_class) }; |
40 | my $err = $@; # so we don't lose it |
41 | if (! $err) { |
efe6365b |
42 | return 1; |
7dd382fb |
43 | } |
44 | else { |
45 | my $fn = (join ('/', split ('::', $f_class) ) ) . '.pm'; |
46 | if ($err =~ /Can't locate ${fn} in \@INC/ ) { |
47 | return 0; |
48 | } |
49 | else { |
50 | die $err; |
51 | } |
efe6365b |
52 | } |
c037c03a |
53 | } |
54 | |
227d4dee |
55 | 1; |