407
|
1 package IMPL::Object::PublicSerializable;
|
|
2 use strict;
|
|
3
|
|
4 use IMPL::Const qw(:access);
|
|
5
|
|
6 sub restore {
|
|
7 my ($class,$data,$refSurrogate) = @_;
|
|
8
|
|
9 if ($refSurrogate) {
|
|
10 $refSurrogate->callCTOR(@$data);
|
|
11 return $refSurrogate;
|
|
12 } else {
|
|
13 return $class->new(@$data);
|
|
14 }
|
|
15 }
|
|
16
|
|
17 sub save {
|
|
18 my ($this,$ctx) = @_;
|
|
19
|
|
20 my %seen;
|
|
21
|
|
22 my $val;
|
|
23
|
|
24 defined($val = $this->$_()) and $ctx->AddVar($_,$val) foreach
|
|
25 map $_->name,$this->GetMeta(
|
|
26 'IMPL::Class::PropertyInfo',
|
|
27 sub {
|
|
28 $_->access == ACCESS_PUBLIC and
|
|
29 $_->getter and
|
|
30 $_->setter and
|
|
31 not $_->ownerSet and
|
|
32 not $seen{$_->name} ++
|
|
33 },
|
|
34 1
|
|
35 );
|
|
36 }
|
|
37
|
|
38 1;
|