From: Ricardo SIGNES Date: Thu, 7 Feb 2008 03:39:02 +0000 (+0000) Subject: tweak the initializer args, document set_initial_value X-Git-Tag: 0_53~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c09219327ecf55f83be207b58a80967a1baa199b;p=gitmo%2FClass-MOP.git tweak the initializer args, document set_initial_value --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index bee7036..6bc203a 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -569,6 +569,11 @@ know what you are doing. Set the value without going through the accessor. Note that this may be done to even attributes with just read only accessors. +=item B + +This method sets the value without going through the accessor -- but it is only +called when the instance data is first initialized. + =item B Return the value without going through the accessor. Note that this may be done diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index d1ed877..8c0a73a 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -89,7 +89,7 @@ sub _set_initial_slot_value { }; # most things will just want to set a value, so make it first arg - $instance->$initializer($value, $slot_name, $callback); + $instance->$initializer($value, $callback, $self); } sub initialize_slot { diff --git a/t/024_attribute_initializer.t b/t/024_attribute_initializer.t index cf39b7a..db9aca5 100644 --- a/t/024_attribute_initializer.t +++ b/t/024_attribute_initializer.t @@ -25,7 +25,7 @@ This checks that the initializer is used to set the initial value. reader => 'get_bar', writer => 'set_bar', initializer => sub { - my ($self, $value, $name, $callback) = @_; + my ($self, $value, $callback, $attr) = @_; $callback->($value * 2); }, );