Mercurial > pub > Impl
diff Lib/IMPL/Object/PublicSerializable.pm @ 60:b0c068da93ac
Lazy activation for the configuration objects (final concept)
small fixes
author | wizard |
---|---|
date | Tue, 09 Mar 2010 19:47:39 +0300 |
parents | |
children | 8d0ae27d15c1 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/Object/PublicSerializable.pm Tue Mar 09 19:47:39 2010 +0300 @@ -0,0 +1,35 @@ +package IMPL::Object::PublicSerializable; +use strict; + +use IMPL::Class::Member; + +sub restore { + my ($class,$data,$refSurrogate) = @_; + + if ($refSurrogate) { + $refSurrogate->callCTOR(@$data); + return $refSurrogate; + } else { + return $class->new(@$data); + } +} + +sub save { + my ($this,$ctx) = @_; + + my %seen; + + $ctx->AddVar($_,$this->$_()) foreach + map $_->Name,$this->get_meta( + 'IMPL::Class::PropertyInfo', + sub { + $_->Access == IMPL::Class::Member::MOD_PUBLIC and + $_->canGet and + not $_->ownerSet and + not $seen{$_->Name} ++ + }, + 1 + ); +} + +1; \ No newline at end of file