From: Fuji, Goro Date: Sat, 25 Sep 2010 09:49:49 +0000 (+0900) Subject: Comments X-Git-Tag: 0.72~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74de0f8b7b68f981688e76b4066ad7bbda775375;p=gitmo%2FMouse.git Comments --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index decbfb1..4ac22d2 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -238,7 +238,10 @@ sub add_attribute { Carp::carp(qq{Attribute ($name) of class }.$self->name .qq{ has no associated methods (did you mean to provide an "is" argument?)}); } + if(!Mouse::Util::MOUSE_XS) { + # in Mouse::PurePerl, attribute initialization code is cached, so it + # must be clear here. See _initialize_object() in Mouse::PurePerl. delete $self->{_initialize_object}; } return $attr; diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index fefcbcc..1bd7c3f 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -317,12 +317,13 @@ sub clone_object { my $cloned = bless { %$object }, ref $object; $class->_initialize_object($cloned, $args, 1); - return $cloned; } sub _initialize_object{ my($self, $object, $args, $is_cloning) = @_; + # The initializer, which is used everywhere, must be clear + # when an attribute is added. See Mouse::Meta::Class::add_attribute. my $initializer = $self->{_initialize_object} ||= do { Mouse::Util::load_class($self->constructor_class) ->_generate_initialize_object($self);