summaryrefslogtreecommitdiff
path: root/lib/Data/MultiValued/TagContainerForRanges.pm
blob: 115276b41edc2ae86f97aad43f7ce21418f24557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package Data::MultiValued::TagContainerForRanges; 
{
  $Data::MultiValued::TagContainerForRanges::VERSION = '0.0.1_3';
}
{
  $Data::MultiValued::TagContainerForRanges::DIST = 'Data-MultiValued';
}
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 
 
 
extends 'Data::MultiValued::TagContainer';
 
has '+_storage' => (
    isa => HashRef[class_type('Data::MultiValued::RangeContainer')],
);
 
has '+_default_tag' => (
    isa => class_type('Data::MultiValued::RangeContainer'),
);
 
 
sub _create_new_inferior {
    Data::MultiValued::RangeContainer->new();
}
 
 
sub _rebless_storage {
    my ($self) = @_;
    bless $_,'Data::MultiValued::RangeContainer'
        for values %{$self->{_storage}};
    bless $self->{_default_tag},'Data::MultiValued::RangeContainer';
    return;
}
 
 
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;
 
__END__
=pod
 
=encoding utf-8
 
=head1 NAME
 
Data::MultiValued::TagContainerForRanges - container for tagged values that are ranged containers
 
=head1 VERSION
 
version 0.0.1_3
 
=head1 DESCRIPTION
 
Please don't use this module directly, use
L<Data::MultiValued::TagsAndRanges>.
 
This module is a subclass of L<Data::MultiValued::TagContainer>, which
only allows instances of L<Data::MultiValued::RangeContainer> as
"storage cells".
 
=head1 METHODS
 
=head2 C<_create_new_inferior>
 
Returns a new L<Data::MultiValued::RangeContainer> instance.
 
=head1 Serialisation helpers
 
These are used through
L<Data::MultiValued::UglySerializationHelperRole>.
 
=head2 C<_rebless_storage>
 
Blesses the "storage cells" into L<Data::MultiValued::RangeContainer>.
 
=head2 C<_as_hash>
 
Returns the internal representation with no blessed hashes, with as
few copies as possible.
 
=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