diff options
Diffstat (limited to 'lib/DeWeave/Collection.pm')
-rw-r--r-- | lib/DeWeave/Collection.pm | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/DeWeave/Collection.pm b/lib/DeWeave/Collection.pm index 6ad87eb..874ea94 100644 --- a/lib/DeWeave/Collection.pm +++ b/lib/DeWeave/Collection.pm @@ -43,20 +43,27 @@ sub from_json { DEBUG '$args ',{filter=>\&pp,value=>$args}; - my @items; + my @items;my %deletions; for my $input_item (@$args) { - my $item; - try { - $item = $class->item_class->new({%$input_item,__crypt=>$crypt}) + my $item_args = DeWeave::WBO->unpack_args($input_item,$crypt); + + if (exists $item_args->{deleted}) { + $deletions{$item_args->{id}}=undef; + next; } - catch { - die $_ unless ref($_) && $_->isa('DeWeave::Exception::Deleted'); - }; + + # the $item_args is passed to allow subclasses to + # generate objects of different types for different inputs + my $item = $class->item_class($item_args) + ->new($item_args); + push @items,$item if $item; } + @items = grep { ! exists $deletions{$_->id} } @items; + return $class->new({ items => \@items, }); |