| Object-Recorder documentation | Contained in the Object-Recorder distribution. |
Object::Recorder::Storage - Serializable data structure for Object::Recorder
This module makes it possible to record method calls issued to a set of objects inti a serializable container which can later be replayed, perfoming the actual method calls.
Builds a new storage object.
Arbitrary method calls are stored using AUTOLOAD. It will return another Object::Recorder::Storage instance so that method calls on return values from another recorded method calls will also be properly recorded.
Nilson Santos Figueiredo Junior, <nilsonsfj at cpan.org>
Copyright (C) 2007 Nilson Santos Figueiredo Junior. Copyright (C) 2007 Picturetrail, Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Object-Recorder documentation | Contained in the Object-Recorder distribution. |
package Object::Recorder::Storage; use warnings; use strict;
our $VERSION = '0.01';
sub new { my $class = shift; my ($object_class, $constructor, @args) = @_; bless { calls => [], object_class => $object_class, constructor => $constructor, args => \@args }, $class; }
our $AUTOLOAD; sub AUTOLOAD { my ($self, @args) = @_; my ($method) = ($AUTOLOAD =~ /::([^:]+?)$/); return if $method eq 'DESTROY'; # only handle methods which return just one value my $return = (ref $self)->new; push @{$self->{calls}}, { method => $method, args => [ @args ], retval => $return }; return $return; }
1;