From: Yuval Kogman Date: Fri, 8 Aug 2008 22:46:18 +0000 (+0000) Subject: slots as a hash is a hack in Instance, partway fix for this X-Git-Tag: 0_64_01~70 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c7fd8691722d6afa446e53d1f4c9e8f9657075d;p=gitmo%2FClass-MOP.git slots as a hash is a hack in Instance, partway fix for this --- diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index 05d7ae3..7349abc 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -24,7 +24,7 @@ sub new { my %options = @args; - # fixme lazy_build + # FIXME lazy_build $options{slots} ||= [ map { $_->slots } @{ $options{attributes} || [] } ]; # FIXME replace with a proper constructor @@ -40,7 +40,8 @@ sub new { # assumption,.. but you can # never tell <:) 'meta' => $options{metaclass}, # FIXME rename to associated metaclass with a compat alias? - 'slots' => { map { $_ => undef } @{ $options{slots} } }, + 'slots' => $options{slots}, + 'slot_hash' => { map { $_ => undef } @{ $options{slots} } }, # FIXME lazy_build } => $class; # FIXME weak_ref => 1, @@ -70,12 +71,12 @@ sub clone_instance { sub get_all_slots { my $self = shift; - return keys %{$self->{'slots'}}; + return @{$self->{'slots'}}; } sub is_valid_slot { my ($self, $slot_name) = @_; - exists $self->{'slots'}->{$slot_name}; + exists $self->{'slot_hash'}->{$slot_name}; } # operations on created instances