From: Jesse Luehrs Date: Thu, 11 Nov 2010 02:43:26 +0000 (-0600) Subject: stop duplicating code here X-Git-Tag: 1.9900~36 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a315f4b0c6b14bffc21f3337127c6335b7ec15f;p=gitmo%2FMoose.git stop duplicating code here --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index e59ebaf..2532e32 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -509,29 +509,13 @@ sub _call_builder { ## Slot management -# FIXME: -# this duplicates too much code from -# Class::MOP::Attribute, we need to -# refactor these bits eventually. -# - SL -sub _set_initial_slot_value { - my ($self, $meta_instance, $instance, $value) = @_; - - my $slot_name = $self->name; - - return $meta_instance->set_slot_value($instance, $slot_name, $value) - unless $self->has_initializer; - - my $callback = sub { - my $val = $self->_coerce_and_verify( shift, $instance );; - - $meta_instance->set_slot_value($instance, $slot_name, $val); +sub _make_initializer_writer_callback { + my $self = shift; + my ($meta_instance, $instance, $slot_name) = @_; + my $old_callback = $self->SUPER::_make_initializer_writer_callback(@_); + return sub { + $old_callback->($self->_coerce_and_verify($_[0], $instance)); }; - - my $initializer = $self->initializer; - - # most things will just want to set a value, so make it first arg - $instance->$initializer($value, $callback, $self); } sub set_value {