view Lib/IMPL/Object/PublicSerializable.pm @ 290:7b0dad6117d5

*TTView: fixed memory leak
author sergey
date Wed, 20 Feb 2013 17:24:57 +0400
parents 4ddb27ff4a0b
children 8088779e539d
line wrap: on
line source

package IMPL::Object::PublicSerializable;
use strict;

use IMPL::Const qw(:access);

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->GetMeta(
            'IMPL::Class::PropertyInfo',
            sub {
                $_->access == ACCESS_PUBLIC and
                $_->getter and
                not $_->ownerSet and
                not $seen{$_->name} ++
            },
            1
        );
}

1;