diff options
Diffstat (limited to 'lib/Data/MultiValued')
-rw-r--r-- | lib/Data/MultiValued/AttributeAccessors.pm | 31 | ||||
-rw-r--r-- | lib/Data/MultiValued/AttributeTrait.pm | 31 | ||||
-rw-r--r-- | lib/Data/MultiValued/AttributeTrait/Ranges.pm | 39 | ||||
-rw-r--r-- | lib/Data/MultiValued/AttributeTrait/Tags.pm | 39 | ||||
-rw-r--r-- | lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm | 39 | ||||
-rw-r--r-- | lib/Data/MultiValued/Exceptions.pm | 63 | ||||
-rw-r--r-- | lib/Data/MultiValued/RangeContainer.pm | 31 | ||||
-rw-r--r-- | lib/Data/MultiValued/Ranges.pm | 127 | ||||
-rw-r--r-- | lib/Data/MultiValued/TagContainer.pm | 31 | ||||
-rw-r--r-- | lib/Data/MultiValued/TagContainerForRanges.pm | 31 | ||||
-rw-r--r-- | lib/Data/MultiValued/Tags.pm | 93 | ||||
-rw-r--r-- | lib/Data/MultiValued/TagsAndRanges.pm | 87 | ||||
-rw-r--r-- | lib/Data/MultiValued/UglySerializationHelperRole.pm | 31 |
13 files changed, 664 insertions, 9 deletions
diff --git a/lib/Data/MultiValued/AttributeAccessors.pm b/lib/Data/MultiValued/AttributeAccessors.pm index cac3538..abe2459 100644 --- a/lib/Data/MultiValued/AttributeAccessors.pm +++ b/lib/Data/MultiValued/AttributeAccessors.pm @@ -1,4 +1,10 @@ package Data::MultiValued::AttributeAccessors; +BEGIN { + $Data::MultiValued::AttributeAccessors::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::AttributeAccessors::DIST = 'Data-MultiValued'; +} use strict; use warnings; use base 'Moose::Meta::Method::Accessor'; @@ -107,3 +113,28 @@ sub _generate_multi_clearer_method { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::AttributeAccessors + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/AttributeTrait.pm b/lib/Data/MultiValued/AttributeTrait.pm index 91e1b13..afeea2e 100644 --- a/lib/Data/MultiValued/AttributeTrait.pm +++ b/lib/Data/MultiValued/AttributeTrait.pm @@ -1,4 +1,10 @@ package Data::MultiValued::AttributeTrait; +BEGIN { + $Data::MultiValued::AttributeTrait::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::AttributeTrait::DIST = 'Data-MultiValued'; +} use Moose::Role; use Data::MultiValued::AttributeAccessors; use MooseX::Types::Moose qw(Str); @@ -227,3 +233,28 @@ sub _as_hash { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::AttributeTrait + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/AttributeTrait/Ranges.pm b/lib/Data/MultiValued/AttributeTrait/Ranges.pm index 8d93578..347ee96 100644 --- a/lib/Data/MultiValued/AttributeTrait/Ranges.pm +++ b/lib/Data/MultiValued/AttributeTrait/Ranges.pm @@ -1,4 +1,10 @@ package Data::MultiValued::AttributeTrait::Ranges; +BEGIN { + $Data::MultiValued::AttributeTrait::Ranges::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::AttributeTrait::Ranges::DIST = 'Data-MultiValued'; +} use Moose::Role; use Data::MultiValued::Ranges; with 'Data::MultiValued::AttributeTrait'; @@ -7,8 +13,39 @@ sub multivalue_storage_class { 'Data::MultiValued::Ranges' }; sub opts_to_pass_set { qw(from to) } sub opts_to_pass_get { qw(at) } -package Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges;{ +package Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges; +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges::VERSION = '0.0.1'; +} +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges::DIST = 'Data-MultiValued'; +}{ sub register_implementation { 'Data::MultiValued::AttributeTrait::Ranges' } } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::AttributeTrait::Ranges + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/AttributeTrait/Tags.pm b/lib/Data/MultiValued/AttributeTrait/Tags.pm index 7cffb33..4355ebe 100644 --- a/lib/Data/MultiValued/AttributeTrait/Tags.pm +++ b/lib/Data/MultiValued/AttributeTrait/Tags.pm @@ -1,4 +1,10 @@ package Data::MultiValued::AttributeTrait::Tags; +BEGIN { + $Data::MultiValued::AttributeTrait::Tags::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::AttributeTrait::Tags::DIST = 'Data-MultiValued'; +} use Moose::Role; use Data::MultiValued::Tags; with 'Data::MultiValued::AttributeTrait'; @@ -7,8 +13,39 @@ sub multivalue_storage_class { 'Data::MultiValued::Tags' }; sub opts_to_pass_set { qw(tag) } sub opts_to_pass_get { qw(tag) } -package Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags;{ +package Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags; +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags::VERSION = '0.0.1'; +} +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags::DIST = 'Data-MultiValued'; +}{ sub register_implementation { 'Data::MultiValued::AttributeTrait::Tags' } } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::AttributeTrait::Tags + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm b/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm index e0c56cd..20b4acd 100644 --- a/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm +++ b/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm @@ -1,4 +1,10 @@ package Data::MultiValued::AttributeTrait::TagsAndRanges; +BEGIN { + $Data::MultiValued::AttributeTrait::TagsAndRanges::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::AttributeTrait::TagsAndRanges::DIST = 'Data-MultiValued'; +} use Moose::Role; use Data::MultiValued::TagsAndRanges; with 'Data::MultiValued::AttributeTrait'; @@ -7,8 +13,39 @@ sub multivalue_storage_class { 'Data::MultiValued::TagsAndRanges' }; sub opts_to_pass_set { qw(from to tag) } sub opts_to_pass_get { qw(at tag) } -package Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges;{ +package Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges; +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges::VERSION = '0.0.1'; +} +BEGIN { + $Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges::DIST = 'Data-MultiValued'; +}{ sub register_implementation { 'Data::MultiValued::AttributeTrait::TagsAndRanges' } } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::AttributeTrait::TagsAndRanges + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/Exceptions.pm b/lib/Data/MultiValued/Exceptions.pm index 8d444c0..77a9e22 100644 --- a/lib/Data/MultiValued/Exceptions.pm +++ b/lib/Data/MultiValued/Exceptions.pm @@ -1,5 +1,17 @@ package Data::MultiValued::Exceptions; -package Data::MultiValued::Exceptions::NotFound;{ +BEGIN { + $Data::MultiValued::Exceptions::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Exceptions::DIST = 'Data-MultiValued'; +} +package Data::MultiValued::Exceptions::NotFound; +BEGIN { + $Data::MultiValued::Exceptions::NotFound::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Exceptions::NotFound::DIST = 'Data-MultiValued'; +}{ use Moose; extends 'Throwable::Error'; @@ -18,7 +30,13 @@ sub as_string { } } -package Data::MultiValued::Exceptions::TagNotFound;{ +package Data::MultiValued::Exceptions::TagNotFound; +BEGIN { + $Data::MultiValued::Exceptions::TagNotFound::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Exceptions::TagNotFound::DIST = 'Data-MultiValued'; +}{ use Moose; extends 'Data::MultiValued::Exceptions::NotFound'; @@ -26,7 +44,13 @@ has '+message' => ( default => 'tag not found: ', ); } -package Data::MultiValued::Exceptions::RangeNotFound;{ +package Data::MultiValued::Exceptions::RangeNotFound; +BEGIN { + $Data::MultiValued::Exceptions::RangeNotFound::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Exceptions::RangeNotFound::DIST = 'Data-MultiValued'; +}{ use Moose; extends 'Data::MultiValued::Exceptions::NotFound'; @@ -34,7 +58,13 @@ has '+message' => ( default => 'no range found for value ', ); } -package Data::MultiValued::Exceptions::BadRange;{ +package Data::MultiValued::Exceptions::BadRange; +BEGIN { + $Data::MultiValued::Exceptions::BadRange::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Exceptions::BadRange::DIST = 'Data-MultiValued'; +}{ use Moose; extends 'Throwable::Error'; @@ -55,3 +85,28 @@ sub as_string { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::Exceptions + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/RangeContainer.pm b/lib/Data/MultiValued/RangeContainer.pm index e9b1b62..69dcc38 100644 --- a/lib/Data/MultiValued/RangeContainer.pm +++ b/lib/Data/MultiValued/RangeContainer.pm @@ -1,4 +1,10 @@ package Data::MultiValued::RangeContainer; +BEGIN { + $Data::MultiValued::RangeContainer::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::RangeContainer::DIST = 'Data-MultiValued'; +} use Moose; use Moose::Util::TypeConstraints; use MooseX::Types::Moose qw(Num Str Any Undef ArrayRef); @@ -194,3 +200,28 @@ sub _splice_slot { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::RangeContainer + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/Ranges.pm b/lib/Data/MultiValued/Ranges.pm index 9c69626..296ae76 100644 --- a/lib/Data/MultiValued/Ranges.pm +++ b/lib/Data/MultiValued/Ranges.pm @@ -1,4 +1,10 @@ package Data::MultiValued::Ranges; +BEGIN { + $Data::MultiValued::Ranges::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Ranges::DIST = 'Data-MultiValued'; +} use Moose; use MooseX::Params::Validate; use Moose::Util::TypeConstraints; @@ -6,7 +12,8 @@ use MooseX::Types::Moose qw(Num Str Undef Any); use Data::MultiValued::Exceptions; use Data::MultiValued::RangeContainer; -# ABSTRACT: Handle values with tags and validity ranges +# ABSTRACT: Handle values with validity ranges + has _storage => ( is => 'rw', @@ -32,6 +39,7 @@ sub _as_hash { return {_storage=>\%ret}; } + sub set { my ($self,%args) = validated_hash( \@_, @@ -44,6 +52,7 @@ sub set { ->{value} = $args{value}; } + sub get { my ($self,%args) = validated_hash( \@_, @@ -54,6 +63,7 @@ sub get { ->{value}; } + sub clear { my ($self,%args) = validated_hash( \@_, @@ -66,3 +76,118 @@ sub clear { 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::Ranges - Handle values with validity ranges + +=head1 VERSION + +version 0.0.1 + +=head1 SYNOPSIS + + use Data::MultiValued::Ranges; + + my $obj = Data::MultiValued::Ranges->new(); + $obj->set({ + from => 10, + to => 20, + value => 'foo', + }); + say $obj->get({at => 15}); # prints 'foo' + say $obj->get({at => 35}); # dies + +=head1 METHODS + +=head2 C<set> + + $obj->set({ from => $min, to => $max, value => $the_value }); + +Stores the given value for the given range. Does not throw exceptions. + +The range is defined as C<< Num $x : $min <= $x < $max >>. A C<< from +=> undef >> means "from -Inf", and a C<< to => undef >> means "to ++Inf". Not passing in C<from> or C<to> is equivalent to passing +C<undef>. + +If the given range intersects existing ranges, these are spliced to +avoid overlaps. In other words: + + $obj->set({ + from => 10, + to => 20, + value => 'foo', + }); + $obj->set({ + from => 15, + to => 25, + value => 'bar', + }); + say $obj->get({at => 12}); # prints 'foo' + say $obj->get({at => 15}); # prints 'bar' + say $obj->get({at => 25}); # dies + +No cloning is done: if you pass in a reference, the reference is +just stored. + +=head2 C<get> + + my $value = $obj->get({ at => $point }); + +Retrieves the value for the given point. Throws a +L<Data::MultiValued::Exceptions::RangeNotFound> exception if no ranges +exist in this object that include the point (remember that a range +does not include its C<to> point). + +A C<< at => undef >> means "at -Inf". Not passing in C<at> is +equivalent to passing C<undef>. + +No cloning is done: if a reference was stored, you get it back +untouched. + +=head2 C<clear> + + $obj->clear({ from => $min, to => $max }); + +Deletes all values for the given range. Does not throw exceptions. + +A C<< from => undef >> means "from -Inf", and a C<< to => undef >> +means "to +Inf". Not passing in C<from> or C<to> is equivalent to +passing C<undef>. Thus, C<< $obj->clear() >> clears everything. + +If the given range intersects existing ranges, these are spliced. In +other words: + + $obj->set({ + from => 10, + to => 20, + value => 'foo', + }); + $obj->clear({ + from => 15, + to => 25, + }); + say $obj->get({at => 12}); # prints 'foo' + say $obj->get({at => 15}); # dies + +=head1 SEE ALSO + +L<Data::MultiValued::RangeContainer>, L<Data::MultiValued::Exceptions> + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/TagContainer.pm b/lib/Data/MultiValued/TagContainer.pm index cdd0456..a65115b 100644 --- a/lib/Data/MultiValued/TagContainer.pm +++ b/lib/Data/MultiValued/TagContainer.pm @@ -1,4 +1,10 @@ package Data::MultiValued::TagContainer; +BEGIN { + $Data::MultiValued::TagContainer::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::TagContainer::DIST = 'Data-MultiValued'; +} use Moose; use Moose::Util::TypeConstraints; use MooseX::Types::Moose qw(HashRef); @@ -97,3 +103,28 @@ sub _create_new_inferior { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::TagContainer + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/TagContainerForRanges.pm b/lib/Data/MultiValued/TagContainerForRanges.pm index d3cd4b9..27af25a 100644 --- a/lib/Data/MultiValued/TagContainerForRanges.pm +++ b/lib/Data/MultiValued/TagContainerForRanges.pm @@ -1,4 +1,10 @@ package Data::MultiValued::TagContainerForRanges; +BEGIN { + $Data::MultiValued::TagContainerForRanges::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::TagContainerForRanges::DIST = 'Data-MultiValued'; +} use Moose; use MooseX::Types::Moose qw(HashRef); use Moose::Util::TypeConstraints; @@ -36,3 +42,28 @@ sub _as_hash { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::TagContainerForRanges + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/Tags.pm b/lib/Data/MultiValued/Tags.pm index fbf7948..a42caf4 100644 --- a/lib/Data/MultiValued/Tags.pm +++ b/lib/Data/MultiValued/Tags.pm @@ -1,4 +1,10 @@ package Data::MultiValued::Tags; +BEGIN { + $Data::MultiValued::Tags::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::Tags::DIST = 'Data-MultiValued'; +} use Moose; use MooseX::Params::Validate; use Moose::Util::TypeConstraints; @@ -6,7 +12,8 @@ use MooseX::Types::Moose qw(Num Str Undef Any); use Data::MultiValued::Exceptions; use Data::MultiValued::TagContainer; -# ABSTRACT: Handle values with tags and validity ranges +# ABSTRACT: Handle values with tags + has _storage => ( is => 'rw', @@ -32,6 +39,7 @@ sub _as_hash { return {_storage=>\%ret}; } + sub set { my ($self,%args) = validated_hash( \@_, @@ -43,6 +51,7 @@ sub set { ->{value} = $args{value}; } + sub get { my ($self,%args) = validated_hash( \@_, @@ -53,6 +62,7 @@ sub get { ->{value}; } + sub clear { my ($self,%args) = validated_hash( \@_, @@ -62,4 +72,85 @@ sub clear { $self->_storage->clear(\%args); } + 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::Tags - Handle values with tags + +=head1 VERSION + +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. + +Not passing in a C<tag> is equivalent to passing in C<< tag => undef +>>. + +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 if the tag +does not exists in this object. + +Not passing in a C<tag> is equivalent to passing in C<< tag => undef +>>. + +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. + +Not passing in a C<tag> clears everything. Yes, this means that there +is no way to just clear the value for the C<undef> tag. + +=head1 SEE ALSO + +L<Data::MultiValued::TagContainer>, L<Data::MultiValued::Exceptions> + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/TagsAndRanges.pm b/lib/Data/MultiValued/TagsAndRanges.pm index 6208435..0217a69 100644 --- a/lib/Data/MultiValued/TagsAndRanges.pm +++ b/lib/Data/MultiValued/TagsAndRanges.pm @@ -1,4 +1,10 @@ package Data::MultiValued::TagsAndRanges; +BEGIN { + $Data::MultiValued::TagsAndRanges::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::TagsAndRanges::DIST = 'Data-MultiValued'; +} use Moose; use MooseX::Params::Validate; use Moose::Util::TypeConstraints; @@ -8,6 +14,7 @@ use Data::MultiValued::TagContainerForRanges; # ABSTRACT: Handle values with tags and validity ranges + has _storage => ( is => 'rw', isa => class_type('Data::MultiValued::TagContainerForRanges'), @@ -33,6 +40,7 @@ sub _as_hash { return {_storage=>$ret}; } + sub set { my ($self,%args) = validated_hash( \@_, @@ -47,6 +55,7 @@ sub set { ->{value} = $args{value}; } + sub get { my ($self,%args) = validated_hash( \@_, @@ -59,6 +68,7 @@ sub get { ->{value}; } + sub clear { my ($self,%args) = validated_hash( \@_, @@ -77,3 +87,80 @@ sub clear { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::TagsAndRanges - Handle values with tags and validity ranges + +=head1 VERSION + +version 0.0.1 + +=head1 SYNOPSIS + + use Data::MultiValued::TagsAndRanges; + + my $obj = Data::MultiValued::TagsAndRanges->new(); + $obj->set({ + tag => 'tag1', + from => 10, + to => 20, + value => 'foo', + }); + say $obj->get({tag => 'tag1', at => 15}); # prints 'foo' + say $obj->get({tag => 'tag1', at => 35}); # dies + say $obj->get({tag => 'tag2', at => 15}); # dies + +=head1 METHODS + +=head2 C<set> + + $obj->set({ tag => $the_tag, from => $min, to => $max, value => $the_value }); + +Stores the given value for the given tag and range. Does not throw +exceptions. + +See L<Data::MultiValued::Tags/set> and +L<Data::MultiValued::Ranges/set> for more details. + +=head2 C<get> + + my $value = $obj->get({ tag => $the_tag, at => $point }); + +Retrieves the value for the given tag and point. Throws a +L<Data::MultiValued::Exceptions::RangeNotFound> exception if no ranges +exist in this object that include the point, and +L<Data::MultiValued::Exceptions::TagNotFound> exception if the tag +does not exists in this object. + +See L<Data::MultiValued::Tags/get> and +L<Data::MultiValued::Ranges/get> for more details. + +=head2 C<clear> + + $obj->clear({ tag => $the_tag, from => $min, to => $max }); + +If a range is specified, deletes all values for the given range and +tag. If no range is specified, delete all values for the given tag. + +Does not throw exceptions. + +See L<Data::MultiValued::Tags/clear> and +L<Data::MultiValued::Ranges/clear> for more details. + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + diff --git a/lib/Data/MultiValued/UglySerializationHelperRole.pm b/lib/Data/MultiValued/UglySerializationHelperRole.pm index e586dec..60de111 100644 --- a/lib/Data/MultiValued/UglySerializationHelperRole.pm +++ b/lib/Data/MultiValued/UglySerializationHelperRole.pm @@ -1,4 +1,10 @@ package Data::MultiValued::UglySerializationHelperRole; +BEGIN { + $Data::MultiValued::UglySerializationHelperRole::VERSION = '0.0.1'; +} +BEGIN { + $Data::MultiValued::UglySerializationHelperRole::DIST = 'Data-MultiValued'; +} use Moose::Role; sub new_in_place { @@ -33,3 +39,28 @@ sub as_hash { } 1; + +__END__ +=pod + +=head1 NAME + +Data::MultiValued::UglySerializationHelperRole + +=head1 VERSION + +version 0.0.1 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=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 + |