annotate lib/IMPL/Object/PublicSerializable.pm @ 408:5c80e33f1218 ref20150831

added 'coarsen' function
author cin
date Mon, 07 Sep 2015 01:35:25 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::Object::PublicSerializable;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4 use IMPL::Const qw(:access);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 sub restore {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 my ($class,$data,$refSurrogate) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 if ($refSurrogate) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 $refSurrogate->callCTOR(@$data);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 return $refSurrogate;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 return $class->new(@$data);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 sub save {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 my ($this,$ctx) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 my %seen;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 my $val;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 defined($val = $this->$_()) and $ctx->AddVar($_,$val) foreach
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 map $_->name,$this->GetMeta(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 'IMPL::Class::PropertyInfo',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 sub {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 $_->access == ACCESS_PUBLIC and
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 $_->getter and
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30 $_->setter and
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 not $_->ownerSet and
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 not $seen{$_->name} ++
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 1
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 1;