package Data::MultiValued::TagContainerForRanges; use Moose; use MooseX::Types::Moose qw(HashRef); use Moose::Util::TypeConstraints; use Data::MultiValued::RangeContainer; # ABSTRACT: container for tagged values that are ranged containers =head1 DESCRIPTION Please don't use this module directly, use L. This module is a subclass of L, which only allows instances of L as "storage cells". =cut extends 'Data::MultiValued::TagContainer'; has '+_storage' => ( isa => HashRef[class_type('Data::MultiValued::RangeContainer')], ); has '+_default_tag' => ( isa => class_type('Data::MultiValued::RangeContainer'), ); =method C<_create_new_inferior> Returns a new L instance. =cut sub _create_new_inferior { Data::MultiValued::RangeContainer->new(); } =head1 Serialisation helpers These are used through L. =head2 C<_rebless_storage> Blesses the "storage cells" into L. =cut sub _rebless_storage { my ($self) = @_; bless $_,'Data::MultiValued::RangeContainer' for values %{$self->{_storage}}; bless $self->{_default_tag},'Data::MultiValued::RangeContainer'; return; } =head2 C<_as_hash> Returns the internal representation with no blessed hashes, with as few copies as possible. =cut sub _as_hash { my ($self) = @_; my %st; for my $k (keys %{$self->_storage}) { my %v = %{$self->_storage->{$k}}; $st{$k}=\%v; } my %dt = %{$self->_default_tag}; return { _storage => \%st, _default_tag => \%dt, }; } 1;