view Lib/IMPL/Object/PublicSerializable.pm @ 67:9f5795a10939

Documentation, minor fixes
author wizard
date Fri, 19 Mar 2010 20:06:12 +0300
parents 8d0ae27d15c1
children d1676be8afcc
line wrap: on
line source

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;
	
	my $val;
	
	defined($val = $this->$_()) and $ctx->AddVar($_,$val) 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;