Group
Extension

Matches 2

Moo-Role-ToJSON ( K/KW/KWAKWA/Moo-Role-ToJSON-0.02.tar.gz, KWAKWA, 2018; MetaCPAN )
Moo-Role-ToJSON/scripts/benchmark.pl ( view source; MetaCPAN )
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() },
    }
);
Moo-Role-ToJSON ( K/KW/KWAKWA/Moo-Role-ToJSON-0.02.tar.gz, KWAKWA, 2018; MetaCPAN )
Moo-Role-ToJSON/lib/Moo/Role/ToJSON.pm ( view source; MetaCPAN )
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 =>

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.