diff options
-rw-r--r-- | lib/Data/MultiValued/TagContainerForRanges.pm | 9 | ||||
-rw-r--r-- | t/json.t | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/Data/MultiValued/TagContainerForRanges.pm b/lib/Data/MultiValued/TagContainerForRanges.pm index d3cd4b9..604dcb7 100644 --- a/lib/Data/MultiValued/TagContainerForRanges.pm +++ b/lib/Data/MultiValued/TagContainerForRanges.pm @@ -20,14 +20,19 @@ sub _create_new_inferior { sub _rebless_storage { my ($self) = @_; - bless $self->{_storage},'Data::MultiValued::RangeContainer'; + bless $_,'Data::MultiValued::RangeContainer' + for values %{$self->{_storage}}; bless $self->{_default_tag},'Data::MultiValued::RangeContainer'; return; } sub _as_hash { my ($self) = @_; - my %st = %{$self->_storage}; + my %st; + for my $k (keys %{$self->_storage}) { + my %v = %{$self->_storage->{$k}}; + $st{$k}=\%v; + } my %dt = %{$self->_default_tag}; return { _storage => \%st, @@ -43,10 +43,12 @@ use Data::Printer; use JSON::XS; my $opts={tag=>'something'}; +my $ropts={tag=>'something',from=>10,to=>20}; my $json = JSON::XS->new->utf8; my $obj = Foo->new(rr=>'foo'); $obj->tt_multi($opts,1234); +$obj->ttrr_multi($ropts,777); my $hash = $obj->as_hash; note p $hash; my $str = $json->encode($hash); @@ -60,6 +62,7 @@ note p $obj2; is($obj2->tt,$obj->tt,'tt'); is($obj2->tt_multi($opts),$obj->tt_multi($opts),'tt tagged'); +is($obj2->ttrr_multi({at => 15}),$obj->ttrr_multi({at => 15}),'ttrr'); is($obj2->rr,$obj->rr,'rr'); done_testing; |