From: Shawn M Moore Date: Wed, 11 Jun 2008 11:04:07 +0000 (+0000) Subject: Use compute_all_applicable_attributes instead of get_attribute_map in the constructor... X-Git-Tag: 0.04~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28d269491e4b8dad61231390965529c3993a2ba5;p=gitmo%2FMouse.git Use compute_all_applicable_attributes instead of get_attribute_map in the constructor, a test for the former --- diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index bec6519..2138adf 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -23,7 +23,7 @@ sub new { my $instance = bless {}, $class; - for my $attribute (values %{ $class->meta->get_attribute_map }) { + for my $attribute ($class->meta->compute_all_applicable_attributes) { my $from = $attribute->init_arg; my $key = $attribute->name; my $default; diff --git a/t/028-subclass-attr.t b/t/028-subclass-attr.t index 527e048..2ec4e6e 100644 --- a/t/028-subclass-attr.t +++ b/t/028-subclass-attr.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 3; do { package Class; @@ -25,3 +25,9 @@ do { my $obj = Child->new(class => 1, child => 1); ok($obj->child, "local attribute set in constructor"); ok($obj->class, "inherited attribute set in constructor"); + +is_deeply([Child->meta->compute_all_applicable_attributes], [ + Child->meta->get_attribute('child'), + Class->meta->get_attribute('class'), +], "correct compute_all_applicable_attributes"); +