Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

moosex::oneargnew(3pm) [debian man page]

MooseX::OneArgNew(3pm)					User Contributed Perl Documentation				    MooseX::OneArgNew(3pm)

NAME
MooseX::OneArgNew - teach ->new to accept single, non-hashref arguments VERSION
version 0.002 SYNOPSIS
In our class definition: package Delivery; use Moose; with('MooseX::OneArgNew' => { type => 'Existing::Message::Type', init_arg => 'message', }); has message => (isa => 'Existing::Message::Type', required => 1); has to => ( is => 'ro', isa => 'Str', lazy => 1, default => sub { my ($self) = @_; $self->message->get('To'); }, ); When making a message: # The traditional way: my $delivery = Delivery->new({ message => $message }); # or my $delivery = Delivery->new({ message => $message, to => $to }); # With one-arg new: my $delivery = Delivery->new($message); DESCRIPTION
MooseX::OneArgNew lets your constructor take a single argument, which will be translated into the value for a one-entry hashref. It is a parameterized role with two parameters: type The Moose type that the single argument must be for the one-arg form to work. This should be an existing type, and may be either a string type or a MooseX::Type. init_arg This is the string that will be used as the key for the hashref constructed from the one-arg call to new. WARNINGS You can apply MooseX::OneArgNew more than once, but if more than one application's type matches a single argument to "new", the behavior is undefined and likely to cause bugs. It would be a very bad idea to supply a type that could accept a normal hashref of arguments to "new". AUTHOR
Ricardo Signes <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.3 2011-06-15 MooseX::OneArgNew(3pm)

Check Out this Related Man Page

MooseX::Has::Sugar::Minimal(3pm)			User Contributed Perl Documentation			  MooseX::Has::Sugar::Minimal(3pm)

NAME
MooseX::Has::Sugar::Minimal - Less Sugary Syntax for moose 'has' fields VERSION
version 0.05070420 SYNOPSIS
This is a legacy variant of Sugar which only exports "ro" and "rw" functions, the way MooseX::Has::Sugar used to with ":is"; use MooseX::Types::Moose qw( Str ); use MooseX::Has::Sugar::Minimal; has foo => ( isa => Str, is => ro, required => 1, ); has bar => ( isa => Str, is => rw, lazy_build => 1, ); All functions are exported by The Sub::Exporter Module. EXPORT GROUPS
:default Exports ":is" :is Exports "bare", "ro", "rw" EXPORTED FUNCTIONS
bare returns "('bare')" ro returns "('ro')" rw returns "('rw')" CONFLICTS
MooseX::Has::Sugar MooseX::Has::Sugar::Saccharin This module is not intended to be used in conjunction with ::Sugar or ::Sugar::Saccharin. We all export "ro" and "rw" in different ways. If you do however want to use them in conjunction, specific imports must be done on MooseX::Has::Sugar's side to stop it exporting different ro/rw. Any of the below should be fine. use MooseX::Has::Sugar::Minimal; use MooseX::Has::Sugar qw( :attrs ); has foo =>( is => rw , lazy_build ); use MooseX::Has::Sugar::Minimal; use MooseX::Has::Sugar qw( lazy_build ); has foo =>( is => rw , lazy_build ); AUTHOR
Kent Fredric <kentnl at cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Kent Fredric. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-02-12 MooseX::Has::Sugar::Minimal(3pm)
Man Page