X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FAttribute.pm;h=894df4bac7678aa6df79eae6d7d14fc0d04146e0;hp=c4068e1b19952417a1691a68a7f4dee2a45a4535;hb=refs%2Ftags%2F0.48;hpb=bd76a699d654075009bb9fd707021721eecf8299 diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index c4068e1..894df4b 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -10,23 +10,22 @@ sub new { my $class = shift; my $name = shift; - my %args = (@_ == 1) ? %{ $_[0] } : @_; - + my $args = $class->Mouse::Object::BUILDARGS(@_); # XXX: for backward compatibility (with method modifiers) if($class->can('canonicalize_args') != \&canonicalize_args){ - %args = $class->canonicalize_args($name, %args); + %{$args} = $class->canonicalize_args($name, %{$args}); } - $class->_process_options($name, \%args); + $class->_process_options($name, $args); - $args{name} = $name; + $args->{name} = $name; - my $self = bless \%args, $class; + my $self = bless $args, $class; # extra attributes if($class ne __PACKAGE__){ - $class->meta->_initialize_object($self, \%args); + $class->meta->_initialize_object($self, $args); } # XXX: there is no fast way to check attribute validity @@ -136,18 +135,19 @@ sub _throw_type_constraint_error { } sub clone_and_inherit_options{ - my($self, %args) = @_; + my $self = shift; + my $args = $self->Mouse::Object::BUILDARGS(@_); - my($attribute_class, @traits) = ref($self)->interpolate_class(\%args); + my($attribute_class, @traits) = ref($self)->interpolate_class($args); - $args{traits} = \@traits if @traits; + $args->{traits} = \@traits if @traits; # do not inherit the 'handles' attribute foreach my $name(keys %{$self}){ - if(!exists $args{$name} && $name ne 'handles'){ - $args{$name} = $self->{$name}; + if(!exists $args->{$name} && $name ne 'handles'){ + $args->{$name} = $self->{$name}; } } - return $attribute_class->new($self->name, %args); + return $attribute_class->new($self->name, $args); } sub clone_parent { # DEPRECATED @@ -334,7 +334,7 @@ Mouse::Meta::Attribute - The Mouse attribute metaclass =head1 VERSION -This document describes Mouse version 0.47 +This document describes Mouse version 0.48 =head1 METHODS