diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-08-07 22:28:04 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-09-03 16:50:15 -0400 |
commit | 3e19fb26f62ce9fa02e417c015f6668989d1eaad (patch) | |
tree | 411f3292cf712606ad177b5229314eb739db4b7b /lib/Reply/Plugin/DataDump.pm | |
parent | 7df1338f58d10c01cf8f742832b57b2736dbf301 (diff) | |
download | reply-3e19fb26f62ce9fa02e417c015f6668989d1eaad.tar.gz reply-3e19fb26f62ce9fa02e417c015f6668989d1eaad.zip |
convert all of the plugins
Diffstat (limited to 'lib/Reply/Plugin/DataDump.pm')
-rw-r--r-- | lib/Reply/Plugin/DataDump.pm | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/Reply/Plugin/DataDump.pm b/lib/Reply/Plugin/DataDump.pm index 850d0b2..a2e90e2 100644 --- a/lib/Reply/Plugin/DataDump.pm +++ b/lib/Reply/Plugin/DataDump.pm @@ -1,9 +1,9 @@ -package Reply::Plugin::DataDump; +package main; use strict; use warnings; # ABSTRACT: format results using Data::Dump -use base 'Reply::Plugin'; +use mop; use Data::Dump 'dumpf'; use overload (); @@ -23,14 +23,9 @@ value. =cut -sub new { - my $class = shift; - my %opts = @_; - $opts{respect_stringification} = 1 - unless defined $opts{respect_stringification}; - - my $self = $class->SUPER::new(@_); - $self->{filter} = sub { +class Reply::Plugin::DataDump extends Reply::Plugin { + has $respect_stringification = 1; + has $filter = sub { my ($ctx, $ref) = @_; return unless $ctx->is_blessed; my $stringify = overload::Method($ref, '""'); @@ -38,15 +33,15 @@ sub new { return { dump => $stringify->($ref), }; - } if $opts{respect_stringification}; + }; - return $self; -} + submethod BUILD { + undef $filter unless $respect_stringification; + } -sub mangle_result { - my $self = shift; - my (@result) = @_; - return @result ? dumpf(@result, $self->{filter}) : (); + method mangle_result (@result) { + return @result ? dumpf(@result, $filter) : (); + } } 1; |