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=4feac11dd03d1b2e5118ce42ee7d5d153bf715f2;hp=67889db8e38940114bf074d6bf0b64d66beef970;hb=4a29b63e8d38182682b0c13ac0260f708cb1b89f;hpb=72e60273ff56052a78344eb0ea2af882f3ede200 diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 67889db..4feac11 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -72,7 +72,8 @@ sub _process_options{ $args->{type_constraint} = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint($args->{isa}); } elsif(exists $args->{does}){ - $args->{type_constraint} = Mouse::Util::TypeConstraints::find_or_create_does_type_constraint($args->{does}); + # TODO + # $args->{type_constraint} = Mouse::Util::TypeConstraints::find_or_create_does_type_constraint($args->{does}); } $tc = $args->{type_constraint}; @@ -203,8 +204,6 @@ sub _create_args { $_[0]->{_create_args} } -sub accessor_metaclass { 'Mouse::Meta::Method::Accessor' } - sub interpolate_class{ my($class, $name, $args) = @_; @@ -277,7 +276,7 @@ sub verify_type_constraint_error { sub coerce_constraint { ## my($self, $value) = @_; my $type = $_[0]->{type_constraint} or return $_[1]; - return Mouse::Util::TypeConstraints->typecast_constraints($_[0]->associated_class->name, $_[0]->type_constraint, $_[1]); + return Mouse::Util::TypeConstraints->typecast_constraints($_[0]->associated_class->name, $type, $_[1]); } sub _canonicalize_handles { @@ -299,7 +298,7 @@ sub clone_and_inherit_options{ my $self = shift; my $name = shift; - return ref($self)->new($name, %{$self}, @_ == 1 ? %{$_[0]} : @_); + return ref($self)->new($name, %{$self}, (@_ == 1) ? %{$_[0]} : @_); } sub clone_parent { @@ -312,7 +311,7 @@ sub clone_parent { . "Use \$meta->add_attribute and \$attr->install_accessors instead."); - $self->create($class, $name, %args); + $self->clone_and_inherited_args($class, $name, %args); } sub get_parent_args { @@ -333,17 +332,19 @@ sub install_accessors{ my($attribute) = @_; my $metaclass = $attribute->{associated_class}; - my $generator_class = $attribute->accessor_metaclass; foreach my $type(qw(accessor reader writer predicate clearer handles)){ if(exists $attribute->{$type}){ my $installer = '_install_' . $type; - $generator_class->$installer($attribute, $attribute->{$type}, $metaclass); + + Mouse::Meta::Method::Accessor->$installer($attribute, $attribute->{$type}, $metaclass); + $attribute->{associated_methods}++; } } if($attribute->can('create') != \&create){ + # backword compatibility $attribute->create($metaclass, $attribute->name, %{$attribute}); }