From: Rafael Kitover Date: Mon, 19 Jul 2010 20:53:01 +0000 (-0400) Subject: make Moose class detection safer X-Git-Tag: 0.07001~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=906fa2169f061a1a118c02120cf13fde6b88dc22;p=dbsrgits%2FDBIx-Class-Schema-Loader.git make Moose class detection safer --- diff --git a/Makefile.PL b/Makefile.PL index c0c83ca..c5c38a2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -33,6 +33,7 @@ requires 'Data::Dumper::Concise' => '1.200'; requires 'Scope::Guard' => 0; requires 'List::MoreUtils' => 0; requires 'Exporter' => '5.63'; +requires 'Try::Tiny' => 0; install_script 'script/dbicdump'; diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index ede47bd..35f9495 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -20,6 +20,7 @@ use Data::Dumper::Concise; use Scalar::Util 'looks_like_number'; use File::Slurp 'slurp'; use DBIx::Class::Schema::Loader::Utils 'split_name'; +use Try::Tiny; require DBIx::Class; use namespace::clean; @@ -1107,7 +1108,7 @@ sub _reload_classes { local *Class::C3::reinitialize = sub {}; use warnings; - if ($class->can('meta') && (ref $class->meta)->isa('Moose::Meta::Class')) { + if ($class->can('meta') && try { (ref $class->meta)->isa('Moose::Meta::Class') }) { $class->meta->make_mutable; } Class::Unload->unload($class) if $unload; @@ -1118,7 +1119,7 @@ sub _reload_classes { && ($resultset_class ne 'DBIx::Class::ResultSet') ) { my $has_file = Class::Inspector->loaded_filename($resultset_class); - if ($resultset_class->can('meta') && (ref $resultset_class->meta)->isa('Moose::Meta::Class')) { + if ($resultset_class->can('meta') && try { (ref $resultset_class->meta)->isa('Moose::Meta::Class') }) { $resultset_class->meta->make_mutable; } Class::Unload->unload($resultset_class) if $unload;