X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FImmutable.pm;h=0ddc75a0a154e80e22d5fba7cdc03201ee2cd302;hb=0bfc85b88523ddd75e0868d6ec1244f4365bda07;hp=2318346ec3a3636e22ed2f28285c69d50dd67047;hpb=26ffbb36c3741396b796f1049a86b87cb8319c0d;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index 2318346..0ddc75a 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -31,12 +31,11 @@ sub new { $metaclass = $options{metaclass}; } - # FIXME make a proper constructor using ->meta->new_object - my $self = bless { + my $self = $class->_new( 'metaclass' => $metaclass, 'options' => $options, 'immutable_metaclass' => undef, - } => $class; + ); # NOTE: # we initialize the immutable @@ -47,6 +46,13 @@ sub new { return $self; } +sub _new { + my $class = shift; + my $options = @_ == 1 ? $_[0] : {@_}; + + bless $options, $class; +} + sub immutable_metaclass { (shift)->{'immutable_metaclass'} } sub metaclass { (shift)->{'metaclass'} } sub options { (shift)->{'options'} }