summaryrefslogtreecommitdiff
path: root/lib/Data/MultiValued/Tags.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/MultiValued/Tags.pm')
-rw-r--r--lib/Data/MultiValued/Tags.pm51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/Data/MultiValued/Tags.pm b/lib/Data/MultiValued/Tags.pm
index 51f7cdb..7295db8 100644
--- a/lib/Data/MultiValued/Tags.pm
+++ b/lib/Data/MultiValued/Tags.pm
@@ -14,6 +14,7 @@ use Data::MultiValued::TagContainer;
# ABSTRACT: Handle values with tags and validity ranges
+
has _storage => (
is => 'rw',
isa => class_type('Data::MultiValued::TagContainer'),
@@ -38,6 +39,7 @@ sub _as_hash {
return {_storage=>\%ret};
}
+
sub set {
my ($self,%args) = validated_hash(
\@_,
@@ -49,6 +51,7 @@ sub set {
->{value} = $args{value};
}
+
sub get {
my ($self,%args) = validated_hash(
\@_,
@@ -59,6 +62,7 @@ sub get {
->{value};
}
+
sub clear {
my ($self,%args) = validated_hash(
\@_,
@@ -68,6 +72,7 @@ sub clear {
$self->_storage->clear(\%args);
}
+
1;
__END__
@@ -81,6 +86,52 @@ Data::MultiValued::Tags - Handle values with tags and validity ranges
version 0.0.1
+=head1 SYNOPSIS
+
+ use Data::MultiValued::Tags;
+
+ my $obj = Data::MultiValued::Tags->new();
+ $obj->set({
+ tag => 'tag1',
+ value => 'a string',
+ });
+ say $obj->get({tag=>'tag1'}); # prints 'a string'
+ say $obj->get({tag=>'tag2'}); # dies
+
+=head1 METHODS
+
+=head2 C<set>
+
+ $obj->set({ tag => $the_tag, value => $the_value });
+
+Stores the given value for the given tag. Replaces existing
+values. Does not throw exceptions.
+
+No cloning is done: if you pass in a reference, the reference is
+just stored.
+
+=head2 C<get>
+
+ my $value = $obj->get({ tag => $the_tag });
+
+Retrieves the value for the given tag. Throws a
+L<Data::MultiValued::Exceptions::TagNotFound> exception it the tag
+does not exists in this object.
+
+No cloning is done: if a reference was stored, you get it back
+untouched.
+
+=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.
+
+=head1 SEE ALSO
+
+L<Data::MultiValued::TagContainer>, L<Data::MultiValued::Exceptions>
+
=head1 AUTHOR
Gianni Ceccarelli <dakkar@thenautilus.net>