From: Stevan Little Date: Sun, 13 Aug 2006 20:13:03 +0000 (+0000) Subject: Moose::Object->dump, cause I am sick of manually loading Data::Dumper all the time X-Git-Tag: 0_12~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f742dfef187b2d0f19826bcc31fdd9c64fd060c1;p=gitmo%2FMoose.git Moose::Object->dump, cause I am sick of manually loading Data::Dumper all the time --- diff --git a/Changes b/Changes index f1bba76..a9fade9 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,10 @@ Revision history for Perl extension Moose * Moose - added ROADMAP section to detail the near term plans for Moose + + * Moose::Object + - added &dump method, cause it makes all out lives + easier really. 0.11 Wed. July 12, 2006 * Moose diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index b0c1676..e754eb4 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -57,6 +57,22 @@ sub does { return 0; } +# RANT: +# Cmon, how many times have you written +# the following code while debugging: +# +# use Data::Dumper; +# warn Dumper \%thing; +# +# It can get seriously annoying, so why +# not just do this ... +sub dump { + my $self = shift; + require Data::Dumper; + $Data::Dumper::Maxdepth = shift if @_; + Data::Dumper::Dumper $self; +} + 1; __END__ @@ -104,6 +120,15 @@ This will call every C method in the inheritance hierarchy. This will check if the invocant's class C a given C<$role_name>. This is similar to C for object, but it checks the roles instead. +=item B + +Cmon, how many times have you written the following code while debugging: + + use Data::Dumper; + warn Dumper $obj; + +It can get seriously annoying, so why not just use this. + =back =head1 BUGS