diff options
author | dakkar <dakkar@thenautilus.net> | 2011-03-27 14:33:59 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2011-03-27 14:37:30 +0100 |
commit | c9af26b1194f693cd55fd9a7850bc168aeba7d27 (patch) | |
tree | f15e7ac877c3b9e3428318c7d91897665b54a581 /lib/DeWeave/Collection.pm | |
parent | many more BrowserObjects (diff) | |
download | DeWeave-c9af26b1194f693cd55fd9a7850bc168aeba7d27.tar.gz DeWeave-c9af26b1194f693cd55fd9a7850bc168aeba7d27.tar.bz2 DeWeave-c9af26b1194f693cd55fd9a7850bc168aeba7d27.zip |
rework object creation
now we unpack args before calling ->new
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, }); |