38 |
} |
} |
39 |
} |
} |
40 |
|
|
41 |
$storage->{scratch}{ref($self)}{$storage->id($obj)}{$member} = { |
$self->set_load_state($storage, $obj, $member, map { $_ => ($coll{$_} && $storage->id( $coll{$_} ) ) } keys %coll ); |
|
map { $_ => ($coll{$_} && $storage->id( $coll{$_} ) ) } keys %coll }; |
|
42 |
|
|
43 |
return \%coll; |
return \%coll; |
44 |
} |
} |
45 |
|
|
46 |
|
sub save_content |
47 |
|
{ |
48 |
|
my ($obj, $field, $context) = @_; |
49 |
|
|
50 |
|
# has collection been loaded? if not, then it hasn't been modified |
51 |
|
return if tied $obj->{$field}; |
52 |
|
return unless exists $obj->{$field} && defined $obj->{$field}; |
53 |
|
|
54 |
|
my $storage = $context->{storage}; |
55 |
|
|
56 |
|
foreach my $item (values %{ $obj->{$field} }) { |
57 |
|
$storage->insert($item) |
58 |
|
unless $storage->id($item); |
59 |
|
} |
60 |
|
} |
61 |
|
|
62 |
|
sub get_exporter |
63 |
|
{ |
64 |
|
my ($self, $context) = @_; |
65 |
|
my $field = $self->{name}; |
66 |
|
|
67 |
|
return sub { |
68 |
|
my ($obj, $context) = @_; |
69 |
|
|
70 |
|
return if tied $obj->{$field}; |
71 |
|
return unless exists $obj->{$field} && defined $obj->{$field}; |
72 |
|
|
73 |
|
my $storage = $context->{storage}; |
74 |
|
|
75 |
|
foreach my $item (values %{ $obj->{$field} }) { |
76 |
|
$storage->insert($item) |
77 |
|
unless $storage->id($item); |
78 |
|
} |
79 |
|
|
80 |
|
$context->{storage}->defer(sub { $self->defered_save($obj, $field, $storage) } ); |
81 |
|
(); |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
1; |
1; |