[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88
Tomas Doran
bobtfish at bobtfish.net
Mon May 6 11:56:39 UTC 2013
The following commit has been merged in the master branch:
commit 2851a5d1bddde823578bfb316a7885082df58b4b
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Sat Feb 25 13:21:43 2012 +0000
Deflate MooseX::Storage classes automatically
diff --git a/lib/Log/Stash/Role/Output.pm b/lib/Log/Stash/Role/Output.pm
index 9f371db..4d933be 100644
--- a/lib/Log/Stash/Role/Output.pm
+++ b/lib/Log/Stash/Role/Output.pm
@@ -1,9 +1,14 @@
package Log::Stash::Role::Output;
use Moose::Role;
use JSON qw/ to_json /;
+use Scalar::Util qw/ blessed /;
use namespace::autoclean;
-sub encode { to_json( $_[1], { utf8 => 1 } ) }
+sub encode {
+ my ($self, $message) = @_;
+ $message = $message->pack if blessed($message) && $message->can('pack');
+ to_json( $message, { utf8 => 1 } )
+}
requires 'consume';
diff --git a/t/output_encode.t b/t/output_encode.t
new file mode 100644
index 0000000..ce42fb1
--- /dev/null
+++ b/t/output_encode.t
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+use Test::More;
+use Try::Tiny;
+
+{
+ package Message;
+ use strict;
+ use warnings;
+
+ sub pack { { foo => "bar" } }
+}
+
+use Log::Stash::Output::Test;
+
+my $test = Log::Stash::Output::Test->new();
+my $packed = $test->encode(bless {}, 'Message');
+
+is $packed, '{"foo":"bar"}';
+
+done_testing;
+
--
libmessage-passing-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list