From: Shawn M Moore Date: Tue, 10 Jun 2008 03:27:48 +0000 (+0000) Subject: Moose compat: Remove Mouse::Class->attributes method in favor of get_attribute_map X-Git-Tag: 0.04~59 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=f89acace2fa0fd5e6b8c4ac40ab1794f1ca62887 Moose compat: Remove Mouse::Class->attributes method in favor of get_attribute_map --- diff --git a/lib/Mouse/Class.pm b/lib/Mouse/Class.pm index a094887..c43c12d 100644 --- a/lib/Mouse/Class.pm +++ b/lib/Mouse/Class.pm @@ -49,7 +49,6 @@ sub add_attribute { $self->{'attributes'}{$attr->name} = $attr; } -sub attributes { values %{ $_[0]->{'attributes'} } } sub get_attribute_map { $_[0]->{attributes} } sub get_attribute { $_[0]->{attributes}->{$_[1]} } @@ -86,10 +85,6 @@ Gets (or sets) the list of superclasses of the owner class. Begins keeping track of the existing L for the owner class. -=head2 attributes -> [Mouse::Attribute] - -Returns a list of L objects. - =head2 get_attribute_map -> { name => Mouse::Attribute } Returns a mapping of attribute names to their corresponding diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 64f2ce4..4af0f39 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -12,7 +12,7 @@ sub new { my %args = @_; my $instance = bless {}, $class; - for my $attribute ($class->meta->attributes) { + for my $attribute (values %{ $class->meta->get_attribute_map }) { my $key = $attribute->init_arg; my $default; diff --git a/t/018-multiattr-has.t b/t/018-multiattr-has.t index 49b4d3d..8fb97f0 100644 --- a/t/018-multiattr-has.t +++ b/t/018-multiattr-has.t @@ -18,7 +18,7 @@ do { }; can_ok(Class => qw/a b c/); -is(Class->meta->attributes, 3, "three attributes created"); +is(keys %{ Class->meta->get_attribute_map }, 3, "three attributes created"); Class->new(a => 1, b => 2); is_deeply(\%trigger, { a => 1, b => 1 }, "correct triggers called"); diff --git a/t/100-meta-class.t b/t/100-meta-class.t index 53f287e..66ffb9d 100644 --- a/t/100-meta-class.t +++ b/t/100-meta-class.t @@ -23,7 +23,7 @@ is_deeply([$meta->superclasses], ['Mouse::Object'], "correctly inherting from Mo my $meta2 = Class->meta; is($meta, $meta2, "same metaclass instance"); -can_ok($meta, 'name', 'attributes', 'get_attribute_map'); +can_ok($meta, 'name', 'get_attribute_map'); my $attr = $meta->get_attribute('pawn'); isa_ok($attr, 'Mouse::Attribute');