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

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

Dependencies

Annotate this POD

Module Version: 0.0.1_4   Source  

NAME ^

Data::MultiValued - store tag- and range-dependant data in a scalar or Moose attribute

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

Also:

  package My::Class;
  use Moose;
  use Data::MultiValued::AttributeTrait::Tags;

  has stuff => (
    is => 'rw',
    isa => 'Int',
    traits => ['MultiValued::Tags'],
  );

  # later

  my $obj = My::Class->new();
  $obj->stuff_multi({tag=>'tag1'},123);
  say $obj->stuff_multi({tag=>'tag1'}); # prints 123

DESCRIPTION ^

This set of classes allows you to store different values inside a single object, and access them by tag and / or by a numeric value.

Yes, you could do the same with hashes and some clever use of arrays. Or you could use Array::IntSpan. Or some other CPAN module. Why use these?

Where to go from here ^

Look at the tests for detailed examples of usage. Look at Data::MultiValued::Tags, Data::MultiValued::Ranges and Data::MultiValued::TagsAndRanges for the containers themselves. Look at Data::MultiValued::AttributeTrait::Tags, Data::MultiValued::AttributeTrait::Ranges and Data::MultiValued::AttributeTrait::TagsAndRanges for the Moose attribute traits.

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: