From: Ricardo SIGNES Date: Wed, 6 Feb 2008 02:01:14 +0000 (+0000) Subject: add public set_initial_value method for Moose to consume setting lazy attrs X-Git-Tag: 0_53~8^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ef91a0e2718b8ca3f386922b3aa19c9c538703d1;p=gitmo%2FClass-MOP.git add public set_initial_value method for Moose to consume setting lazy attrs --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 9b6aae7..bee7036 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -240,6 +240,14 @@ sub associate_method { ## Slot management +sub set_initial_value { + my ($self, $instance, $value) = @_; + + Class::MOP::Class->initialize(blessed($instance)) + ->get_meta_instance + ->_set_initial_slot_value($instance, $self->name, $value, $self->initializer); +} + sub set_value { my ($self, $instance, $value) = @_; diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index afb9c20..6fab683 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 59; +use Test::More tests => 60; use Test::Exception; BEGIN { @@ -39,6 +39,7 @@ BEGIN { slots get_value set_value + set_initial_value has_value clear_value