Net::Google::DataAPI::Role::HasContent - provides 'param' method to Entry


Net-Google-DataAPI documentation Contained in the Net-Google-DataAPI distribution.

Index


Code Index:

NAME

Top

Net::Google::DataAPI::Role::HasContent - provides 'param' method to Entry

SYNOPSIS

Top

    package MyEntry;
    use Any::Moose;
    with qw(
        Net::Google::DataAPI::Role::Entry
        Net::Google::DataAPI::Role::HasContent
    );

    1;

DESCRIPTION

Top

Net::Google::DataAPI::Role::HasContent provides 'param' method to Entry.

AUTHOR

Top

Nobuo Danjou <nobuo.danjou@gmail.com>

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Net-Google-DataAPI documentation Contained in the Net-Google-DataAPI distribution.

package Net::Google::DataAPI::Role::HasContent;
use Any::Moose '::Role';
our $VERSION='0.03';

requires 'update';

has content => (
    isa => 'HashRef',
    is => 'rw',
    lazy_build => 1,
    trigger => sub { $_[0]->update },
);

sub _build_content { +{} }

sub param {
    my ($self, $arg) = @_;
    return $self->content unless $arg;
    if (ref $arg eq 'HASH') {
        return $self->content(
            {
                %{$self->content},
                %$arg,
            }
        );
    } else {
        return $self->content->{$arg};
    }
}

no Any::Moose '::Role';

1;

__END__