add a hook in here for moose to override
Jesse Luehrs [Thu, 11 Nov 2010 01:50:39 +0000 (19:50 -0600)]
lib/Class/MOP/Attribute.pm
t/014_attribute_introspection.t

index bbcf98b..26cd2fb 100644 (file)
@@ -148,16 +148,25 @@ sub _set_initial_slot_value {
     return $meta_instance->set_slot_value($instance, $slot_name, $value)
         unless $self->has_initializer;
 
-    my $callback = sub {
-        $meta_instance->set_slot_value($instance, $slot_name, $_[0]);
-    };
-    
+    my $callback = $self->_make_initializer_writer_callback(
+        $meta_instance, $instance, $slot_name
+    );
+
     my $initializer = $self->initializer;
 
     # most things will just want to set a value, so make it first arg
     $instance->$initializer($value, $callback, $self);
 }
 
+sub _make_initializer_writer_callback {
+    my $self = shift;
+    my ($meta_instance, $instance, $slot_name) = @_;
+
+    return sub {
+        $meta_instance->set_slot_value($instance, $slot_name, $_[0]);
+    };
+}
+
 sub get_read_method  { 
     my $self   = shift;    
     my $reader = $self->reader || $self->accessor;
index 57819e0..6a9bb21 100644 (file)
@@ -22,6 +22,7 @@ use Class::MOP;
 
         initialize_instance_slot
         _set_initial_slot_value
+        _make_initializer_writer_callback
 
         name
         has_accessor      accessor