Class-Persist

 view release on metacpan or  search on metacpan

lib/Class/Persist/Proxy.pm  view on Meta::CPAN

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
      if (my $object = $tracker->object) {
        $self->_duplicate_from($object);
        bless $self => ref($object);
        return $self;
      }
    }
    return $self->record('Class::Persist::Error::DB::NotFound', "Could not load $class for $self", 1)
  }
 
  $self->_duplicate_from( $obj );
  bless $self => $class;
}
 
 
=head2 proxy( $obj )
 
Replace object by proxy
 
=cut
 
sub proxy {

lib/Class/Persist/Proxy.pm  view on Meta::CPAN

151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  $obj->isa('Class::Persist') or Class::Persist::Error::InvalidParameters->throw(text => "object to proxy should be a Class::Persist");
   
  $class->loadModule( ref $obj ) or return;
  my $self = $class->new();
  $self->class( ref $obj );
  if ($owner) {
    $self->owner( $owner );
  }
  $self->real_id( $obj->oid );
  $obj->_duplicate_from( $self );
  bless $obj => $class;
}
 
 
sub AUTOLOAD {
  my $self = shift;
  $self = $self->load() or return; # die "Can't find in DB from ".(caller)[0]." line ".(caller)[2];
  my $meth = substr($AUTOLOAD, rindex($AUTOLOAD, ':') + 1);
  my $can = $self->can($meth) or EO::Error::Method::NotFound->throw(text => "Method $meth unknownin class ".ref($self));
  $can->($self, @_);
}



( run in 0.261 second using v1.01-cache-2.11-cpan-05444aca049 )