X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod%2FAccessor.pm;h=1c0ea404c933ca2a461f5a42258e86c657ade07e;hb=3545c727b64808e435c361e061962d14ba5b3f31;hp=9264eda3c750a20bd642cc412d5af9a8a7ba01ba;hpb=ba38bf08d30369c19a2c25997a0243c0d30be3d5;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index 9264eda..1c0ea40 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -12,19 +12,6 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method'; -=pod - -So, the idea here is that we have an accessor class -which takes a weak-link to the attribute and can -generate the actual code ref needed. This might allow -for more varied approaches. - -And if the attribute type can also declare what -kind of accessor method metaclass it uses, then -this relationship can be handled by delegation. - -=cut - sub new { my $class = shift; my %options = @_; @@ -75,9 +62,7 @@ sub intialize_body { ($self->as_inline ? 'inline' : ()) ); - eval { - $self->{body} = $self->$method_name(); - }; + eval { $self->{body} = $self->$method_name() }; die $@ if $@; } @@ -107,22 +92,16 @@ sub generate_writer_method { } sub generate_predicate_method { - my $attr = (shift)->associated_attribute; - my $attr_name = $attr->name; + my $attr = (shift)->associated_attribute; return sub { - defined Class::MOP::Class->initialize(Scalar::Util::blessed($_[0])) - ->get_meta_instance - ->get_slot_value($_[0], $attr_name) ? 1 : 0; + $attr->has_value($_[0]) }; } sub generate_clearer_method { - my $attr = (shift)->associated_attribute; - my $attr_name = $attr->name; + my $attr = (shift)->associated_attribute; return sub { - Class::MOP::Class->initialize(Scalar::Util::blessed($_[0])) - ->get_meta_instance - ->deinitialize_slot($_[0], $attr_name); + $attr->clear_value($_[0]) }; }