… | |
… | |
356 | |
356 | |
357 | $data = from_json $data; |
357 | $data = from_json $data; |
358 | |
358 | |
359 | for (@$data) { |
359 | for (@$data) { |
360 | my ($name, $args) = @$_; |
360 | my ($name, $args) = @$_; |
|
|
361 | |
361 | attach $obj, $name, %{$args || {} }; |
362 | $obj->attach ($name, %{$args || {} }); |
362 | } |
363 | } |
363 | } |
364 | } |
364 | |
365 | |
365 | # basically do the same as instantiate, without calling instantiate |
366 | # basically do the same as instantiate, without calling instantiate |
366 | sub reattach { |
367 | sub reattach { |
367 | my ($obj) = @_; |
368 | my ($obj) = @_; |
368 | my $registry = $obj->registry; |
369 | my $registry = $obj->registry; |
369 | |
370 | |
370 | @$registry = (); |
371 | @$registry = (); |
371 | |
372 | |
|
|
373 | delete $obj->{_attachment} unless @{ $obj->{_attachment} || [] }; |
|
|
374 | |
372 | for my $name (@{ $obj->{_attachment} }) { |
375 | for my $name (@{ $obj->{_attachment} || [] }) { |
373 | if (my $attach = $attachment{$name}) { |
376 | if (my $attach = $attachment{$name}) { |
374 | for (@$attach) { |
377 | for (@$attach) { |
375 | my ($klass, @attach) = @$_; |
378 | my ($klass, @attach) = @$_; |
376 | _attach @$registry, $klass, @attach; |
379 | _attach @$registry, $klass, @attach; |
377 | } |
380 | } |