From: Yuval Kogman Date: Wed, 13 Aug 2008 21:20:42 +0000 (+0000) Subject: _new for Instance X-Git-Tag: 0_64_01~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4b5d65ac894e44ec070e7a1b827a80c87123ad4;p=gitmo%2FClass-MOP.git _new for Instance --- diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index 46773de..c5aea5e 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -35,7 +35,17 @@ sub new { my $options = $class->BUILDARGS(@_); # FIXME replace with a proper constructor - my $instance = bless { + my $instance = $class->_new(%$options); + + # FIXME weak_ref => 1, + weaken($instance->{'associated_metaclass'}); + + return $instance; +} + +sub _new { + my ( $class, %options ) = @_; + bless { # NOTE: # I am not sure that it makes # sense to pass in the meta @@ -46,16 +56,11 @@ sub new { # which is *probably* a safe # assumption,.. but you can # never tell <:) - 'associated_metaclass' => $options->{associated_metaclass}, - 'attributes' => $options->{attributes}, - 'slots' => $options->{slots}, - 'slot_hash' => $options->{slot_hash}, + 'associated_metaclass' => $options{associated_metaclass}, + 'attributes' => $options{attributes}, + 'slots' => $options{slots}, + 'slot_hash' => $options{slot_hash}, } => $class; - - # FIXME weak_ref => 1, - weaken($instance->{'associated_metaclass'}); - - return $instance; } sub _class_name { $_[0]->{_class_name} ||= $_[0]->associated_metaclass->name }