X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FInstance.pm;h=e3163edd662528f742bf082666933687b256f7f3;hb=e45f0a07c741bb8b8eedbbab139d245fc4cf7c4a;hp=46773de9c1cec51a3ef8a997e3592dab86383529;hpb=becd03c64eba09e26a8936afd316ed2542c51423;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index 46773de..e3163ed 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -6,7 +6,8 @@ use warnings; use Scalar::Util 'weaken', 'blessed'; -our $VERSION = '0.65'; +our $VERSION = '0.68'; +$VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; @@ -35,7 +36,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 +57,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 } @@ -85,6 +91,11 @@ sub get_all_slots { return @{$self->{'slots'}}; } +sub get_all_attributes { + my $self = shift; + return @{$self->{attributes}}; +} + sub is_valid_slot { my ($self, $slot_name) = @_; exists $self->{'slot_hash'}->{$slot_name}; @@ -294,6 +305,12 @@ superclass changes. Defaults to false. +=item B + +This will return the current list of attributes (as +Class::MOP::Attribute objects) based on what was given to this object +in C. + =back =head2 Operations on Instance Structures