}
}
+sub get_attribute_values {
+ my ($self, $instance) = @_;
+
+ return +{
+ map { $_->name => $_->get_value($instance) }
+ grep { $_->has_value($instance) }
+ $self->>compute_all_applicable_attributes
+ };
+}
+
+sub get_init_args {
+ my ($self, $instance) = @_;
+
+ return +{
+ map { $_->init_arg => $_->get_value($instance) }
+ grep { $_->has_value($instance) }
+ grep { defined($_->init_arg) }
+ $self->compute_all_applicable_attributes
+ };
+}
+
# Inheritance
sub superclasses {
think Yuval "nothingmuch" Kogman put it best when he said that cloning
is too I<context-specific> to be part of the MOP.
+=item B<get_attribute_values($instance)>
+
+Returns the values of the C<$instance>'s fields keyed by the attribute names.
+
+=item B<get_init_args($instance)>
+
+Returns a hash reference where the keys are all the attributes' C<init_arg>s
+and the values are the instance's fields. Attributes without an C<init_arg>
+will be skipped.
+
=item B<rebless_instance($instance)>
This will change the class of C<$instance> to the class of the invoking
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
sub is_inlinable { 1 }
=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)>