summaryrefslogtreecommitdiff
path: root/lib/Data/MultiValued/AttributeTrait.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/MultiValued/AttributeTrait.pm')
-rw-r--r--lib/Data/MultiValued/AttributeTrait.pm199
1 files changed, 48 insertions, 151 deletions
diff --git a/lib/Data/MultiValued/AttributeTrait.pm b/lib/Data/MultiValued/AttributeTrait.pm
index d24c6d9..167fc4d 100644
--- a/lib/Data/MultiValued/AttributeTrait.pm
+++ b/lib/Data/MultiValued/AttributeTrait.pm
@@ -291,119 +291,78 @@ version 0.0.1_3
=head1 DESCRIPTION
-=head2 C<slots>
-
-Adds the L</full_storage_slot> to the list of used slots.
-
-=head2 C<set_full_storage>
-
-Stores a new instance of L</multivalue_storage_class> into the
-L</full_storage_slot> of the instance.
-
-=head2 C<get_full_storage>
-
-Retrieves the value of the L</full_storage_slot> of the instance.
-
-=head2 C<full_storage>
-
-Returns an instance of L</multivalue_storage_class>, either by
-retrieving it from the instance, or by creating one (and setting it in
-the instance). Calls L</get_full_storage> and L</set_full_storage>.
-
-=head2 C<accessor_metaclass>
-
-Makes sure that all accessors for this attribute are created via the
-L<Data::MultiValued::AttributeAccessors> method meta class.
-
-=head2 C<install_accessors>
-
-After the regular L<Moose::Meta::Attribute> method, installs the
-multi-value accessors.
-
-Each installed normal accessor gets a multi-value version
-
-You can add or rename the multi-value version by using the attributes
-described above
-
-If you are passing explicit subrefs for your accessors, things won't work.
-
-=head2 C<load_multi_value>
-
-Retrieves a value from the multi-value object, and stores it in the
-regular slot in the instance. If the value is not found, clears the
-slot.
-
-This traps the
-L<Data::MultiValued::Exceptions::NotFound|Data::MultiValued::Exceptions/Data::MultiValued::Exceptions::NotFound>
-exception that may be thrown by the multi-value object, but re-throws
-any other exception.
-
-=head2 C<raw_clear_value>
+Don't use this role directly, use
+L<Data::MultiValued::AttributeTrait::Tags>,
+L<Data::MultiValued::AttributeTrait::Ranges> or
+L<Data::MultiValued::AttributeTrait::TagsAndRanges>.
-Clears the instance slot. Does the same as
-L<Moose::Meta::Attribute/clear_value>, but we need this method because
-the other one gets changed by this trait.
-
-=head2 C<store_multi_value>
-
-Gets the value from the regular slot in the instance, and stores it
-into the multi-value object.
-
-=head2 C<get_value>
+This role (together with L<Data::MultiValued::AttributeAccessors>)
+defines all the basic plumbing to glue C<Data::MultiValued::Tags> etc
+into Moose attributes.
-Before the normal method, calls L</load_multi_value>. Normally, no
-options will be passed to the multi-value object C<get> method.
+=head1 ATTRIBUTES
-=head2 C<get_multi_value>
+=head2 C<full_storage_slot>
-Sets the options that L</load_multi_value> will use, then calls L</get_value>.
+The instance slot to use to store the C<Data::MultiValued::Tags> or
+similar object. Defaults to C<"${name}__MULTIVALUED_STORAGE__">, where
+C<$name> is the attribute name.
-The options are passed via an ugly C<local>ised package
-variable. There might be a better way.
+=head2 C<multi_accessor>
-=head2 C<set_initial_value>
+=head2 C<multi_reader>
-After the normal method, calls L</store_multi_value>.
+=head2 C<multi_writer>
-=head2 C<set_value>
+=head2 C<multi_predicate>
-=head2 C<set_multi_value>
+=head2 C<multi_clearer>
-Just like L</get_value> and L</get_multi_value>, but calling
-L</store_multi_value> after the regular C<set_value>
+The names to use for the various additional accessors. See
+L<Class::MOP::Attribute> for details. These default to
+C<"${name}_multi"> where C<$name> is the name of the corresponding
+non-multi accessor. So, for example,
-=head2 C<has_value>
+ has stuff => (
+ is => 'rw',
+ traits => ['MultiValued::Tags'],
+ );
-=head2 C<has_multi_value>
+will create a C<stuff> read / write accessor and a C<stuff_multi> read
+/ write tagged accessor.
-Just like L</get_value> and L</get_multi_value>.
+=head1 ATTRIBUTES
-=head2 C<clear_value>
+=head2 C<full_storage_slot>
-=head2 C<clear_multi_value>
+The instance slot to use to store the C<Data::MultiValued::Tags> or
+similar object. Defaults to C<"${name}__MULTIVALUED_STORAGE__">, where
+C<$name> is the attribute name.
-Call the C<clear> method on the multi-value object.
+=head2 C<multi_accessor>
-=head2 C<get_multi_read_method>
+=head2 C<multi_reader>
-=head2 C<get_multi_write_method>
+=head2 C<multi_writer>
-Return the name of the reader or writer method, honoring
-L</multi_reader>, L</multi_writer> and L</multi_accessor>.
+=head2 C<multi_predicate>
-=head2 C<_rebless_slot>
+=head2 C<multi_clearer>
-Blesses the value inside the L</full_storage_slot> of the instance
-into L</multivalue_storage_class>, then calls C<_rebless_storage> on
-it.
+The names to use for the various additional accessors. See
+L<Class::MOP::Attribute> for details. These default to
+C<"${name}_multi"> where C<$name> is the name of the corresponding
+non-multi accessor. So, for example,
-=head2 C<_as_hash>
+ has stuff => (
+ is => 'rw',
+ traits => ['MultiValued::Tags'],
+ );
-Returns the result of calling C<_as_hash> on the value inside the
-L</full_storage_slot> of the instance. Returns nothing if the slot
-does not have a value.
+will create a C<stuff> read / write accessor and a C<stuff_multi> read
+/ write tagged accessor.
-=head1 DESCRIPTION
+=head1 METHODS
=head2 C<slots>
@@ -517,68 +476,6 @@ Returns the result of calling C<_as_hash> on the value inside the
L</full_storage_slot> of the instance. Returns nothing if the slot
does not have a value.
-=head1 ATTRIBUTES
-
-=head2 C<full_storage_slot>
-
-The instance slot to use to store the C<Data::MultiValued::Tags> or
-similar object. Defaults to C<"${name}__MULTIVALUED_STORAGE__">, where
-C<$name> is the attribute name.
-
-=head2 C<multi_accessor>
-
-=head2 C<multi_reader>
-
-=head2 C<multi_writer>
-
-=head2 C<multi_predicate>
-
-=head2 C<multi_clearer>
-
-The names to use for the various additional accessors. See
-L<Class::MOP::Attribute> for details. These default to
-C<"${name}_multi"> where C<$name> is the name of the corresponding
-non-multi accessor. So, for example,
-
- has stuff => (
- is => 'rw',
- traits => ['MultiValued::Tags'],
- );
-
-will create a C<stuff> read / write accessor and a C<stuff_multi> read
-/ write tagged accessor.
-
-=head1 ATTRIBUTES
-
-=head2 C<full_storage_slot>
-
-The instance slot to use to store the C<Data::MultiValued::Tags> or
-similar object. Defaults to C<"${name}__MULTIVALUED_STORAGE__">, where
-C<$name> is the attribute name.
-
-=head2 C<multi_accessor>
-
-=head2 C<multi_reader>
-
-=head2 C<multi_writer>
-
-=head2 C<multi_predicate>
-
-=head2 C<multi_clearer>
-
-The names to use for the various additional accessors. See
-L<Class::MOP::Attribute> for details. These default to
-C<"${name}_multi"> where C<$name> is the name of the corresponding
-non-multi accessor. So, for example,
-
- has stuff => (
- is => 'rw',
- traits => ['MultiValued::Tags'],
- );
-
-will create a C<stuff> read / write accessor and a C<stuff_multi> read
-/ write tagged accessor.
-
=head1 Implementation details
The multi-value object is stored in the instance slot named by the