From: Dagfinn Ilmari Mannsåker Date: Tue, 1 Oct 2013 19:41:55 +0000 (+0100) Subject: Stop using the deprecated Class::MOP::load_class() X-Git-Tag: v0.08260~133 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d401ab6b38bd6666b80376bbd91685870529199b;p=dbsrgits%2FDBIx-Class.git Stop using the deprecated Class::MOP::load_class() Use MooseX::Types::LoadableClass instead, requiring the version that fixes the constraints to not throw an exception on syntactically invalid names, so that we can coerce a prefix onto ::Foo. --- diff --git a/Changes b/Changes index c54b3b7..ea0bdfc 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,7 @@ Revision history for DBIx::Class - Throw clearer exception on ->new_related() with a non-existent relationship. - Fix t/storage/replicated.t class loading problem + - Stop using the deprecated Class::MOP::load_class() * Misc - Replace $row with $result in all docs to be consistent and to diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index b0d76b8..0eb6e0c 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -12,6 +12,7 @@ use MooseX::Types::Moose qw/Int Str Any Bool/; use DBIx::Class::Admin::Types qw/DBICConnectInfo DBICHashRef/; use MooseX::Types::JSON qw(JSON); use MooseX::Types::Path::Class qw(Dir File); +use MooseX::Types::LoadableClass qw(LoadableClass); use Try::Tiny; use JSON::Any qw(DWIW XS JSON); use namespace::autoclean; @@ -68,7 +69,7 @@ the class of the schema to load has 'schema_class' => ( is => 'ro', - isa => Str, + isa => LoadableClass, ); @@ -87,8 +88,6 @@ has 'schema' => ( sub _build_schema { my ($self) = @_; - require Class::MOP; - Class::MOP::load_class($self->schema_class); $self->connect_info->[3]{ignore_version} = 1; return $self->schema_class->connect(@{$self->connect_info}); } diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index e1782a0..7b44658 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -18,6 +18,7 @@ my $json_any = { my $moose_basic = { 'Moose' => '0.98', 'MooseX::Types' => '0.21', + 'MooseX::Types::LoadableClass' => '0.011', }; my $replicated = { diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm index fa926a9..0fcb9b2 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Types.pm @@ -11,6 +11,7 @@ use strict; use MooseX::Types -declare => [qw/BalancerClassNamePart Weight DBICSchema DBICStorageDBI/]; use MooseX::Types::Moose qw/ClassName Str Num/; +use MooseX::Types::LoadableClass qw/LoadableClass/; class_type 'DBIx::Class::Storage::DBI'; class_type 'DBIx::Class::Schema'; @@ -19,16 +20,13 @@ subtype DBICSchema, as 'DBIx::Class::Schema'; subtype DBICStorageDBI, as 'DBIx::Class::Storage::DBI'; subtype BalancerClassNamePart, - as ClassName; + as LoadableClass; coerce BalancerClassNamePart, from Str, via { my $type = $_; - if($type=~m/^::/) { - $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; - } - Class::MOP::load_class($type); + $type =~ s/\A::/DBIx::Class::Storage::DBI::Replicated::Balancer::/; $type; };