Mercurial > pub > Impl
comparison lib/IMPL/Object/PublicSerializable.pm @ 407:c6e90e02dd17 ref20150831
renamed Lib->lib
author | cin |
---|---|
date | Fri, 04 Sep 2015 19:40:23 +0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
406:f23fcb19d3c1 | 407:c6e90e02dd17 |
---|---|
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; |