| 1 | # | ||
| 2 | # This file is part of Log-Message-Structured-Stringify-AsSereal | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2013 by Damien "dams" Krotkine. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | package Log::Message::Structured::Stringify::AsSereal; | ||
| 10 | { | ||
| 11 | 2 | $Log::Message::Structured::Stringify::AsSereal::VERSION = '0.11'; | |
| 12 | } | ||
| 13 | 2 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 2 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | 2 | ▶ | use Sereal::Encoder; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 2 | ▶ | use MIME::Base64; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | |||
| 19 | 2 | requires 'as_hash'; | |
| 20 | |||
| 21 | has '_sereal_encoder' => ( | ||
| 22 | is => 'ro', | ||
| 23 | lazy => 1, | ||
| 24 | 1 | ▶ | default => sub { Sereal::Encoder->new( {} ) }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 25 | 2 | ); | |
| 26 | |||
| 27 | |||
| 28 | 2 | ▶ | around 'as_string' => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 29 | 2 | my $orig = shift; | |
| 30 | 2 | my $self = shift; | |
| 31 | 2 | return encode_base64($self->_sereal_encoder->encode($self->as_hash)); | |
| 32 | 2 | }; | |
| 33 | |||
| 34 | |||
| 35 | 2 | 1; | |
| 36 | |||
| 37 | __END__ | ||