stop using Class::MOP::load_class (RT#91003)
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / WithApplicatorDumple.pm
index 971c994..404dbcd 100644 (file)
@@ -1,8 +1,15 @@
 package DBIx::Class::DeploymentHandler::WithApplicatorDumple;
 use MooseX::Role::Parameterized;
-use Class::MOP;
+use Module::Runtime 'use_module';
 use namespace::autoclean;
 
+# this is at least a little ghetto and not super well
+# thought out.  Take a look at the following at some
+# point to clean it all up:
+#
+# http://search.cpan.org/~jjnapiork/MooseX-Role-BuildInstanceOf-0.06/lib/MooseX/Role/BuildInstanceOf.pm
+# http://github.com/rjbs/role-subsystem/blob/master/lib/Role/Subsystem.pm
+
 parameter interface_role => (
   isa      => 'Str',
   required => 1,
@@ -18,11 +25,6 @@ parameter delegate_name => (
   required => 1,
 );
 
-parameter interface_role => (
-  isa      => 'Str',
-  required => 1,
-);
-
 parameter attributes_to_copy => (
   isa => 'ArrayRef[Str]',
   default => sub {[]},
@@ -38,11 +40,12 @@ role {
 
   my $class_name = $p->class_name;
 
-  Class::MOP::load_class($class_name);
+  use_module($class_name);
 
   my $meta = Class::MOP::class_of($class_name);
 
-  has [map %{$_->clone}, map $meta->get_attribute($_), @{ $p->attributes_to_copy }];
+  has $_->name => %{ $_->clone }
+    for grep { $_ } map $meta->find_attribute_by_name($_), @{ $p->attributes_to_copy };
 
   has $p->delegate_name => (
     is         => 'ro',