fix bug reported by Strayph in #moose where a subclass would not inherit the Role...
Chris Prather [Wed, 15 Sep 2010 23:39:19 +0000 (19:39 -0400)]
lib/MooseX/ConfigFromFile.pm
t/02subclass.t [new file with mode: 0644]

index e6b7d44..29e82c9 100644 (file)
@@ -25,7 +25,7 @@ sub new_with_config {
         $configfile = $opts{configfile}
     }
     else {
-        my $cfmeta = $class->meta->get_attribute('configfile');
+        my $cfmeta = $class->meta->find_attribute_by_name('configfile');
         $configfile = $cfmeta->default if $cfmeta->has_default;
     }
 
diff --git a/t/02subclass.t b/t/02subclass.t
new file mode 100644 (file)
index 0000000..fec2590
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl 
+use strict;
+use Test::More;
+use Test::Exception;
+{
+    package A;
+    use Moose;
+    with qw(MooseX::ConfigFromFile);
+    
+    sub get_config_from_file { }
+}
+
+{
+    package B;
+    use Moose;
+    extends qw(A);
+}
+
+ok(B->does('MooseX::ConfigFromFile'), 'B does ConfigFromFile');
+lives_ok { B->new_with_config() } 'B->new_with_config lives';
+
+done_testing();