X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=cf22900843a90cd60fb6a809c37ef33960cce425;hb=8048320ca00e5e1104bf8ea4b3bf74ba5d5cb7fa;hp=d91565393e2145c3dde019ce691cc475ebcfa92a;hpb=2a5dcfb30a71cc41d4edacd37d0bb6c7e2945aba;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index d915653..cf22900 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -14,6 +14,7 @@ use Digest::MD5 qw//; use Lingua::EN::Inflect::Number qw//; use File::Temp qw//; use Class::Unload; +use Class::Inspector (); require DBIx::Class; our $VERSION = '0.05001'; @@ -386,7 +387,12 @@ can also be found via standard L methods somehow. =cut -use constant CURRENT_V => 'v5'; +use constant CURRENT_V => 'v5'; + +use constant CLASS_ARGS => qw( + schema_base_class result_base_class additional_base_classes + left_base_classes additional_classes components resultset_components +); # ensure that a peice of object data is a valid arrayref, creating # an empty one or encapsulating whatever's there. @@ -421,6 +427,8 @@ sub new { resultset_components /); + $self->_validate_class_args; + push(@{$self->{components}}, 'ResultSetManager') if @{$self->{resultset_components}}; @@ -596,6 +604,34 @@ EOF close $fh; } +sub _validate_class_args { + my $self = shift; + my $args = shift; + + foreach my $k (CLASS_ARGS) { + next unless $self->$k; + + my @classes = ref $self->$k eq 'ARRAY' ? @{ $self->$k } : $self->$k; + foreach my $c (@classes) { + # components default to being under the DBIx::Class namespace unless they + # are preceeded with a '+' + if ( $k =~ m/components$/ && $c !~ s/^\+// ) { + $c = 'DBIx::Class::' . $c; + } + + # 1 == installed, 0 == not installed, undef == invalid classname + my $installed = Class::Inspector->installed($c); + if ( defined($installed) ) { + if ( $installed == 0 ) { + croak qq/$c, as specified in the loader option "$k", is not installed/; + } + } else { + croak qq/$c, as specified in the loader option "$k", is an invalid class name/; + } + } + } +} + sub _find_file_in_inc { my ($self, $file) = @_;