X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute.pm;h=640d1cc0caccb9be88138635f40fad4a19239901;hb=e06951bb83e29645bd9186e3180a6af480929050;hp=98627658797a435571f9cc300c2217147481b1ab;hpb=5aab256d5db9e8280781c89158a700bfe897389a;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 9862765..640d1cc 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -9,7 +9,7 @@ use List::MoreUtils 'any'; use Try::Tiny; use overload (); -our $VERSION = '1.08'; +our $VERSION = '1.14'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Deprecated; @@ -134,7 +134,7 @@ sub interpolate_class { # method-generating options shouldn't be overridden sub illegal_options_for_inheritance { - qw(is reader writer accessor clearer predicate) + qw(reader writer accessor clearer predicate) } # NOTE/TODO @@ -577,6 +577,22 @@ sub remove_accessors { return; } +sub inline_set { + my $self = shift; + my ( $instance, $value ) = @_; + + my $mi = $self->associated_class->get_meta_instance; + + my $code + = $mi->inline_set_slot_value( $instance, $self->slots, $value ) . ";"; + $code + .= $mi->inline_weaken_slot_value( $instance, $self->slots, $value ) + . ";" + if $self->is_weak_ref; + + return $code; +} + sub install_delegation { my $self = shift; @@ -836,7 +852,7 @@ object which does the named role. =item * coerce => $bool This option is only valid for objects with a type constraint -(C). If this is true, then coercions will be applied whenever +(C) that defined a coercion. If this is true, then coercions will be applied whenever this attribute is set. You can make both this and the C option true. @@ -963,6 +979,12 @@ methods is almost always an error.) This method overrides the parent to also remove delegation methods. +=item B<< $attr->inline_set($instance_var, $value_var) >> + +This method return a code snippet suitable for inlining the relevant +operation. It expect strings containing variable names to be used in the +inlining, like C<'$self'> or C<'$_[1]'>. + =item B<< $attr->install_delegation >> This method adds its delegation methods to the attribute's associated