MooseX::RemoteHelper - adds an attribute name to represent remote naming
version 0.001010
{ package Message; use Moose 2; with 'MooseX::RemoteHelper::CompositeSerializtion'; use MooseX::RemoteHelper; has bool => ( remote_name => 'Boolean', isa => 'Bool', is => 'ro', serializer => sub { my ( $attr, $instance ) = @_; return $attr->get_value( $instance ) ? 'Y' : 'N'; }, ); has foo_bar => ( remote_name => 'FooBar', isa => 'Str', is => 'ro', ); __PACKAGE__->meta->make_immutable; } my $message = Message->new({ Boolean => 1, foo_bar => 'Baz', }); $message->bool; # 1 $message->serialize; # { Boolean => 'Y', FooBar => 'Baz' }
Many Remote APIs have key names that don't look good in a perl API, such as variants of camel case or even names that you don't want to use simply because they are inconsistent with your Perl API. This module allows you to provide a remote name on your attribute. We also allow you to use the remote name as an init_arg so that you can more easily construct a response from a remote response.
init_arg
How the attributes work is documented in MooseX::RemoteHelper::Meta::Trait::Attribute
for serialize read
MooseX::RemoteHelper::CompositeSerialization
Some of this code is based on or outright copied from MooseX::Aliases
Chris Prather ( Perigrin )
for help getting the basics working and understanding what some of this code does.
Please report any bugs or feature requests on the bugtracker website https://github.com/xenoterracide/MooseX-RemoteHelper/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Please see those modules/websites for more information related to this module.
MooseX::Aliases
Caleb Cushing <xenoterracide@gmail.com>
This software is Copyright (c) 2012 by Caleb Cushing.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install MooseX::RemoteHelper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::RemoteHelper
CPAN shell
perl -MCPAN -e shell install MooseX::RemoteHelper
For more information on module installation, please visit the detailed CPAN module installation guide.