summaryrefslogtreecommitdiff
path: root/lib/Data/MultiValued/TagContainer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/MultiValued/TagContainer.pm')
-rw-r--r--lib/Data/MultiValued/TagContainer.pm150
1 files changed, 90 insertions, 60 deletions
diff --git a/lib/Data/MultiValued/TagContainer.pm b/lib/Data/MultiValued/TagContainer.pm
index ca9093f..949440c 100644
--- a/lib/Data/MultiValued/TagContainer.pm
+++ b/lib/Data/MultiValued/TagContainer.pm
@@ -1,4 +1,10 @@
package Data::MultiValued::TagContainer;
+{
+ $Data::MultiValued::TagContainer::VERSION = '0.0.1_5';
+}
+{
+ $Data::MultiValued::TagContainer::DIST = 'Data-MultiValued';
+}
use Moose;
use namespace::autoclean;
use Moose::Util::TypeConstraints;
@@ -7,21 +13,6 @@ use Data::MultiValued::Exceptions;
# ABSTRACT: container for tagged values
-=head1 DESCRIPTION
-
-Please don't use this module directly, use L<Data::MultiValued::Tags>.
-
-This module implements the storage for tagged data. It's almost
-exactly a hash, the main difference being that C<undef> is a valid key
-and it's distinct from the empty string.
-
-Another difference is that you get an exception if you try to access a
-tag that's not there.
-
-Data is kept in "storage cells", as created by
-L</_create_new_inferior> (by default, a hashref).
-
-=cut
has _storage => (
is => 'rw',
@@ -45,18 +36,6 @@ has _default_tag => (
clearer => '_clear_default_tag',
);
-=method C<get>
-
- my $value = $obj->get({ tag => $the_tag });
-
-Retrieves the "storage cell" for the given tag. Throws a
-L<Data::MultiValued::Exceptions::TagNotFound|Data::MultiValued::Exceptions/Data::MultiValued::Exceptions::TagNotFound>
-exception if the tag does not exists in this object.
-
-Not passing in a C<tag> is equivalent to passing in C<< tag => undef
->>.
-
-=cut
sub get {
my ($self,$args) = @_;
@@ -81,18 +60,6 @@ sub get {
return $self->_get_tag($tag);
}
-=method C<get_or_create>
-
- $obj->get_or_create({ tag => $the_tag });
-
-Retrieves the "storage cell" for the given tag. If the tag does not
-exist, creates a new cell (see L</_create_new_inferior>), sets it for
-the tag, and returns it.
-
-Not passing in a C<tag> is equivalent to passing in C<< tag => undef
->>.
-
-=cut
sub get_or_create {
my ($self,$args) = @_;
@@ -122,18 +89,6 @@ sub _clear_storage {
$self->_storage({});
}
-=method C<clear>
-
- $obj->clear({ tag => $the_tag });
-
-Deletes the given tag and all data associated with it. Does not throw
-exceptions: if the tag does not exist, nothing happens.
-
-Not passing in a C<tag>, or passing C<< tag => undef >>, clears
-everything. If you want to only clear the C<undef> tag, you may call
-C<_clear_default_tag> (which is considered a "protected" method).
-
-=cut
sub clear {
my ($self,$args) = @_;
@@ -150,25 +105,100 @@ sub clear {
return;
}
-=method C<all_tags>
+
+sub _create_new_inferior {
+ my ($self) = @_;
+ return {};
+}
+
+__PACKAGE__->meta->make_immutable();
+
+1;
+
+__END__
+=pod
+
+=encoding utf-8
+
+=head1 NAME
+
+Data::MultiValued::TagContainer - container for tagged values
+
+=head1 VERSION
+
+version 0.0.1_5
+
+=head1 DESCRIPTION
+
+Please don't use this module directly, use L<Data::MultiValued::Tags>.
+
+This module implements the storage for tagged data. It's almost
+exactly a hash, the main difference being that C<undef> is a valid key
+and it's distinct from the empty string.
+
+Another difference is that you get an exception if you try to access a
+tag that's not there.
+
+Data is kept in "storage cells", as created by
+L</_create_new_inferior> (by default, a hashref).
+
+=head1 METHODS
+
+=head2 C<get>
+
+ my $value = $obj->get({ tag => $the_tag });
+
+Retrieves the "storage cell" for the given tag. Throws a
+L<Data::MultiValued::Exceptions::TagNotFound|Data::MultiValued::Exceptions/Data::MultiValued::Exceptions::TagNotFound>
+exception if the tag does not exists in this object.
+
+Not passing in a C<tag> is equivalent to passing in C<< tag => undef
+>>.
+
+=head2 C<get_or_create>
+
+ $obj->get_or_create({ tag => $the_tag });
+
+Retrieves the "storage cell" for the given tag. If the tag does not
+exist, creates a new cell (see L</_create_new_inferior>), sets it for
+the tag, and returns it.
+
+Not passing in a C<tag> is equivalent to passing in C<< tag => undef
+>>.
+
+=head2 C<clear>
+
+ $obj->clear({ tag => $the_tag });
+
+Deletes the given tag and all data associated with it. Does not throw
+exceptions: if the tag does not exist, nothing happens.
+
+Not passing in a C<tag>, or passing C<< tag => undef >>, clears
+everything. If you want to only clear the C<undef> tag, you may call
+C<_clear_default_tag> (which is considered a "protected" method).
+
+=head2 C<all_tags>
my @tags = $obj->all_tags;
Returns all the tags defined in this object. Does not return the
C<undef> tag.
-=method C<_create_new_inferior>
+=head2 C<_create_new_inferior>
Returns a new "storage cell", by default an empty hashref. See
L<Data::MultiValued::TagContainerForRanges> for an example of use.
-=cut
+=head1 AUTHOR
-sub _create_new_inferior {
- my ($self) = @_;
- return {};
-}
+Gianni Ceccarelli <dakkar@thenautilus.net>
-__PACKAGE__->meta->make_immutable();
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2011 by Net-a-Porter.com.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut
-1;