Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

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

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

NAME
MooseX::Param - Simple role to provide a standard param method SYNOPSIS
package My::Template::System; use Moose; with 'MooseX::Param'; # ... my $template = My::Template::System->new( params => { foo => 10, bar => 20, baz => 30, } ); # fetching params $template->param('foo'); # 10 # getting list of params $template->param(); # foo, bar, baz # setting params $template->param(foo => 30, bar => 100); DESCRIPTION
This is a very simple Moose role which provides a CGI like "param" method. I found that I had written this code over and over and over and over again, and each time it was the same. So I thought, why not put it in a role? ATTRIBUTES
params This role provides a "params" attribute which has a read-only accessor, and a HashRef type constraint. It also adds a builder method (see "init_params" method below) to properly initialize it. METHODS
params Return the HASH ref in which the parameters are stored. param This is your standard CGI style "param" method. If passed no arguments, it will return a list of param names. If passed a single name argument it will return the param associated with that name. If passed a key value pair (or set of key value pairs) it will assign them into the params. init_params This is the params attribute "builder" option, so it is called the params are initialized. NOTE: You can override this by defining your own version in your class, because local class methods beat role methods in composition. meta Returns the role metaclass. SIMILAR MODULES
The "param" method can be found in several other modules, such as CGI, CGI::Application and HTML::Template to name a few. This is such a common Perl idiom that I felt it really deserved it's own role (if for nothing more than I was sick of re-writing and copy-pasting it all the time). There are also a few modules which attempt to solve the same problem as this module. Those are: Class::Param This module is much more ambitious than mine, and provides much deeper functionality. For most of my purposes, this module would have been overkill, but if you need really sophisticated param handling and the ability to provide several different APIs (tied, etc), this module is probably the way to go. Mixin::ExtraFields::Param This module is very similar to mine, but for a different framework. It works with the Mixin::ExtraFields framework. BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2007 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-03-29 MooseX::Param(3pm)

Check Out this Related Man Page

MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)		User Contributed Perl Documentation	    MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)

NAME
MooseX::Getopt::Meta::Attribute::NoGetopt - Optional meta attribute for ignoring parameters VERSION
version 0.59 SYNOPSIS
package App; use Moose; with 'MooseX::Getopt'; has 'data' => ( metaclass => 'NoGetopt', # do not attempt to capture this param is => 'ro', isa => 'Str', default => 'file.dat', ); DESCRIPTION
This is a custom attribute metaclass which can be used to specify that a specific attribute should not be processed by "MooseX::Getopt". All you need to do is specify the "NoGetopt" metaclass. has 'foo' => (metaclass => 'MooseX::Getopt::Meta::Attribute::NoGetopt', ... ); Use 'traits' instead of 'metaclass' You should rarely need to explicitly set the attribute metaclass. It is much preferred to simply provide a trait (a role applied to the attribute metaclass), which allows other code to further modify the attribute by applying additional roles. Therefore, you should first try to do this: has 'foo' => (traits => ['NoGetopt', ...], ...); Custom Metaclass alias This now takes advantage of the Moose 0.19 feature to support custom attribute metaclass. This means you can also use this as the NoGetopt alias, like so: has 'foo' => (metaclass => 'NoGetopt', cmd_flag => 'f'); AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc. 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.18.2 2013-11-30 MooseX::Getopt::Meta::Attribute::NoGetopt(3pm)
Man Page