r80228@onn: sartak | 2009-02-17 19:59:17 -0500
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Nopaste.pm
index bff581a..283fdfb 100644 (file)
@@ -3,6 +3,7 @@ package Devel::REPL::Plugin::Nopaste;
 use Devel::REPL::Plugin;
 use MooseX::AttributeHelpers;
 use namespace::clean -except => [ 'meta' ];
+use Scalar::Util qw(blessed);
 
 sub BEFORE_PLUGIN {
     my $self = shift;
@@ -13,6 +14,7 @@ has complete_session => (
     metaclass => 'String',
     is        => 'rw',
     isa       => 'Str',
+    lazy      => 1,
     default   => '',
     provides  => {
         append => 'add_to_session',
@@ -35,8 +37,17 @@ around eval => sub {
     my $line = shift;
 
     my @ret = $orig->($self, $line, @_);
-
-    $self->add_to_session(join("\n", @ret) . "\n\n");
+    my @ret_as_str = map {
+        if (!defined($_)) {
+            '';
+        } elsif (blessed($_) && $_->can('stringify')) {
+            $_->stringify();
+        } else {
+            $_;
+        }
+    } @ret;
+
+    $self->add_to_session(join("\n", @ret_as_str) . "\n\n");
 
     return @ret;
 };