| MouseX-Param documentation | Contained in the MouseX-Param distribution. |
MouseX::Param - A Mouse role for manipulating params
package MyApp;
use Mouse;
with 'MouseX::Param';
package main;
my $app = MyApp->new(params => {
foo => 10,
bar => 20,
});
# getting params
$app->param('foo'); # 10
# getting list of params
$app->param(); # foo, bar
# setting params
$app->param(foo => 30, bar => 40);
MouseX::Param is a simple Mouse role which provides a CGI like
param method.
NAKAGAWA Masaki <masaki@cpan.org>
Stevan Little, AUTHOR in MooseX::Param
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| MouseX-Param documentation | Contained in the MouseX-Param distribution. |
package MouseX::Param; use 5.8.1; use Mouse::Role; our $VERSION = '0.01'; has 'params' => ( is => 'rw', isa => 'HashRef', lazy => 1, default => sub { +{} }, ); sub param { my $self = shift; return keys %{ $self->params } if @_ == 0; return $self->params->{+shift} if @_ == 1; my %params = @_; while (my ($key, $value) = each %params) { $self->params->{$key} = $value; } } no Mouse::Role; 1;