summaryrefslogtreecommitdiff
path: root/lib/DeWeave/Collection.pm
blob: 42669ba4626658d1ff0e661272faa7af7f818943 (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
package DeWeave::Collection; 
use Moose;
use namespace::autoclean;
use MooseX::Types::Moose qw(ArrayRef Int Str Num);
use JSON::Any;
use DeWeave::EDO;
 
has items => (
    isa => ArrayRef['DeWeave::WBO'],
    is => 'ro',
    required => 1,
);
 
sub from_json {
    my ($class,$json,$crypt)=@_;
 
    my $j = JSON::Any->new;
 
    my $args = $j->decode($json);
 
    my @items = map {
        DeWeave::EDO->new({%$_,__crypt=>$crypt})
      @$args;
    return $class->new({
        items => \@items,
    });
}
 
1;