package Data::MultiValued::TagsAndRanges;
{
$Data::MultiValued::TagsAndRanges::VERSION = '0.0.6_1';
}
{
$Data::MultiValued::TagsAndRanges::DIST = 'Data-MultiValued';
}
use Moose;
use namespace::autoclean;
use MooseX::Params::Validate;
use Moose::Util::TypeConstraints;
use Data::MultiValued::Exceptions;
use Data::MultiValued::TagContainerForRanges;
has _storage => (
is => 'rw',
isa => class_type('Data::MultiValued::TagContainerForRanges'),
init_arg => undef,
lazy_build => 1,
);
sub _build__storage {
Data::MultiValued::TagContainerForRanges->new();
}
sub set {
my ($self,%args) = validated_hash(
\@_,
from => { isa => 'Num|Undef', optional => 1, },
to => { isa => 'Num|Undef', optional => 1, },
tag => { isa => 'Str', optional => 1, },
value => { isa => 'Any', },
);
$self->_storage->get_or_create(\%args)
->get_or_create(\%args)
->{value} = $args{value};
}
sub get {
my ($self,%args) = validated_hash(
\@_,
at => { isa => 'Num|Undef', optional => 1, },
tag => { isa => 'Str', optional => 1, },
);
$self->_storage->get(\%args)
->get(\%args)
->{value};
}
sub clear {
my ($self,%args) = validated_hash(
\@_,
from => { isa => 'Num|Undef', optional => 1, },
to => { isa => 'Num|Undef', optional => 1, },
tag => { isa => 'Str', optional => 1, },
);
if (exists $args{from} || exists $args{to}) {
$self->_storage->get(\%args)
->clear(\%args);
}
else {
$self->_storage->clear(\%args);
}
}
sub _rebless_storage {
my ($self) = @_;
bless $self->{_storage},'Data::MultiValued::TagContainerForRanges';
$self->_storage->_rebless_storage;
}
sub _as_hash {
my ($self) = @_;
my $ret = $self->_storage->_as_hash;
return {_storage=>$ret};
}
__PACKAGE__->meta->make_immutable();
1;
__END__