Gianni Ceccarelli > Data-MultiValued-0.0.1_4 > Data::MultiValued::TagContainer

Download:
Data-MultiValued-0.0.1_4.tar.gz

Dependencies

Annotate this POD

Module Version: 0.0.1_4   Source  

NAME ^

Data::MultiValued::TagContainer - container for tagged values

VERSION ^

version 0.0.1_4

DESCRIPTION ^

Please don't use this module directly, use Data::MultiValued::Tags.

This module implements the storage for tagged data. It's almost exactly a hash, the main difference being that 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 "_create_new_inferior" (by default, a hashref).

METHODS ^

get

  my $value = $obj->get({ tag => $the_tag });

Retrieves the "storage cell" for the given tag. Throws a Data::MultiValued::Exceptions::TagNotFound exception if the tag does not exists in this object.

Not passing in a tag is equivalent to passing in tag => undef.

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 "_create_new_inferior"), sets it for the tag, and returns it.

Not passing in a tag is equivalent to passing in tag => undef.

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 tag, or passing tag => undef, clears everything. If you want to only clear the undef tag, you may call _clear_default_tag (which is considered a "protected" method).

all_tags

  my @tags = $obj->all_tags;

Returns all the tags defined in this object. Does not return the undef tag.

_create_new_inferior

Returns a new "storage cell", by default an empty hashref. See Data::MultiValued::TagContainerForRanges for an example of use.

AUTHOR ^

Gianni Ceccarelli <dakkar@thenautilus.net>

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.

syntax highlighting: