e';
# ABSTRACT: benchmark is_attribute_serializable
BEGIN {
package ToJSON::A;
use Moo;
with 'Moo::Role::ToJSON';
has bar => (is => 'ro', default => 'bar');
has foo => (is => 'r
/bar foo/] }
sub is_attribute_serializable { return 1 }
package ToJSON::B;
use Moo;
with 'Moo::Role::ToJSON';
has bar => (is => 'ro', default => 'bar');
has foo => (is => 'r
000_000,
{
'::ToJSON with is_attribute_serializable' => sub { ToJSON::A->new->TO_JSON() },
'::ToJSON wout is_attribute_serializable' => sub { ToJSON::B->new->TO_JSON() },
}
);
package Moo::Role::ToJSON;
use Types::Standard 'ArrayRef';
use Moo::Role;
# ABSTRACT: a Moo role for a TO_JSON method
our $VERSION = '0.02';
has serializable_attributes => (
is => 'lazy',
isa => ArrayRef,
);
sub _build_serializable_attributes { [] }
sub TO_JSON {
my $self = shift;
my @attributes_to_serialize
= $self->can('is_attribute_serializable')
? grep {
coding utf8
=head1 NAME
Moo::Role::ToJSON - a Moo role for a TO_JSON method
=head1 SYNOPSIS
package My::Message;
use Moo;
with 'Moo::Role::ToJSON';
has feel_like_sharing => (is =>