From: Chris Prather Date: Wed, 15 Sep 2010 23:39:19 +0000 (-0400) Subject: fix bug reported by Strayph in #moose where a subclass would not inherit the Role... X-Git-Tag: 0.03~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-ConfigFromFile.git;a=commitdiff_plain;h=7760bb42bcac9434f02e3e2d60a564ea777b31a1;hp=870afbfa171c89e9e1c7e5d2421c8628fa9821c0 fix bug reported by Strayph in #moose where a subclass would not inherit the Role behavior properly --- diff --git a/lib/MooseX/ConfigFromFile.pm b/lib/MooseX/ConfigFromFile.pm index e6b7d44..29e82c9 100644 --- a/lib/MooseX/ConfigFromFile.pm +++ b/lib/MooseX/ConfigFromFile.pm @@ -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 index 0000000..fec2590 --- /dev/null +++ b/t/02subclass.t @@ -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();