Some simplifications and corrections suggested by nothingmuch++
[gitmo/Class-MOP.git] / lib / Class / MOP / Instance.pm
index 008815e..a9612a9 100644 (file)
@@ -108,13 +108,28 @@ sub is_slot_initialized {
 }
 
 sub weaken_slot_value {
-        my ($self, $instance, $slot_name) = @_;
-        weaken $instance->{$slot_name};
+    my ($self, $instance, $slot_name) = @_;
+    weaken $instance->{$slot_name};
 }
 
 sub strengthen_slot_value {
-        my ($self, $instance, $slot_name) = @_;
-        $self->set_slot_value($instance, $slot_name, $self->get_slot_value($instance, $slot_name));
+    my ($self, $instance, $slot_name) = @_;
+    $self->set_slot_value($instance, $slot_name, $self->get_slot_value($instance, $slot_name));
+}
+
+sub rebless_instance_structure {
+    my ($self, $instance, $metaclass) = @_;
+    bless $instance, $metaclass->name;
+}
+
+sub get_all_slot_values {
+    my ($self, $instance) = @_;
+
+    return +{
+        map { $_->name => $_->get_value($instance) }
+            grep { $_->has_value($instance) }
+                $self->associated_metaclass->compute_all_applicable_attributes
+    };
 }
 
 # inlinable operation snippets
@@ -269,6 +284,8 @@ require that the C<$instance_structure> is passed into them.
 
 =item B<set_slot_value ($instance_structure, $slot_name, $value)>
 
+=item B<get_all_slot_values ($instance_structure)>
+
 =item B<initialize_slot ($instance_structure, $slot_name)>
 
 =item B<deinitialize_slot ($instance_structure, $slot_name)>
@@ -283,6 +300,8 @@ require that the C<$instance_structure> is passed into them.
 
 =item B<strengthen_slot_value ($instance_structure, $slot_name)>
 
+=item B<rebless_instance_structure ($instance_structure, $new_metaclass)>
+
 =back
 
 =head2 Inlineable Instance Operations
@@ -329,7 +348,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006, 2007 by Infinity Interactive, Inc.
+Copyright 2006-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>