Skip to content

Commit

Permalink
Implement wrapping of objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Jan 2, 2009
1 parent cbc6908 commit 293c0b7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/Data/Dump/Trace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ our @EXPORT_OK = qw(call mcall wrap);

use Data::Dump qw(dump);
use Term::ANSIColor qw(YELLOW CYAN RESET);
use Carp qw(croak);

my %obj_name;

sub dumpav {
return "(" . dump(@_) . ")" if @_ == 1;
Expand All @@ -29,7 +31,12 @@ sub wrap {

return sub {
call($name, $func, @_);
}
} if $func;

my $obj = $arg{obj};
return bless { name => $name, obj => $obj }, "Data::Dump::Trace::Wrapper" if $obj;

croak("Either the 'func' or 'obj' option must be given");
}

sub call {
Expand Down Expand Up @@ -73,4 +80,13 @@ sub mcall {
}
}

package Data::Dump::Trace::Wrapper;

sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::')+2);
Data::Dump::Trace::mcall($self->{obj}, $method, @_);
}

1;

0 comments on commit 293c0b7

Please sign in to comment.