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

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

Dependencies

Annotate this POD

Module Version: 0.0.1_4   Source  

NAME ^

Data::MultiValued::Tags - Handle values with tags

VERSION ^

version 0.0.1_4

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

METHODS ^

set

  $obj->set({ tag => $the_tag, value => $the_value });

Stores the given value for the given tag. Replaces existing values. Does not throw exceptions.

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

No cloning is done: if you pass in a reference, the reference is just stored.

get

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

Retrieves the value 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.

No cloning is done: if a reference was stored, you get it back untouched.

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 clears everything. Yes, this means that there is no way to just clear the value for the undef tag.

Serialisation helpers ^

These are used through Data::MultiValued::UglySerializationHelperRole.

_rebless_storage

Blesses the storage into Data::MultiValued::TagContainer.

_as_hash

Returns the internal representation with no blessed hashes, with as few copies as possible.

SEE ALSO ^

Data::MultiValued::TagContainer, Data::MultiValued::Exceptions

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: