-
-
06 Feb 2017 02:29:35 UTC
- Distribution: MooseX-SlurpyConstructor
- Module version: 1.30
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (1)
- Testers (4121 / 16 / 0)
- Kwalitee
Bus factor: 1- 96.55% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (33.31KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:1 non-PAUSE user- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- OPTIONAL RESTRICTIONS
- SEE ALSO
- HISTORY
- ACKNOWLEDGEMENTS
- SUPPORT
- AUTHORS
- COPYRIGHT AND LICENSE
NAME
MooseX::SlurpyConstructor - Make your object constructor collect all unknown attributes
VERSION
version 1.30
SYNOPSIS
package My::Class; use Moose; use MooseX::SlurpyConstructor; has fixed => ( is => 'ro', ); has slurpy => ( is => 'ro', slurpy => 1, ); package main; ASDF->new({ fixed => 100, unknown1 => "a", unknown2 => [ 1..3 ] })->dump; # returns: # $VAR1 = bless( { # 'slurpy' => { # 'unknown2' => [ # 1, # 2, # 3 # ], # 'unknown1' => 'a' # }, # 'fixed' => 100 # }, 'ASDF' );
DESCRIPTION
Including this module within Moose-based classes, and declaring an attribute as 'slurpy' will allow capturing of all unknown constructor arguments in the given attribute.
As of Moose 1.9900, this module can also be used in a role, in which case the constructor of the consuming class will become slurpy.
OPTIONAL RESTRICTIONS
No additional options are added to your
slurpy
attribute, so if you want to make it read-only, or restrict its type constraint to aHashRef
of specific types, you should state that yourself. Typical usage may include any or all of the options below:has slurpy => ( is => 'ro', isa => 'HashRef', init_arg => undef, lazy => 1, default => sub { {} }, traits => ['Hash'], handles => { slurpy_values => 'elements', }, );
For more information on these options, see Moose::Manual::Attributes and Moose::Meta::Attribute::Native::Trait::Hash.
SEE ALSO
-
The opposite of this module, making constructors die on unknown arguments. If both of these are used together, MooseX::StrictConstructor will always take precedence.
This module can also be used in migrating code from vanilla Moose to using MooseX::StrictConstructor. That was one of my original motivations for writing it; to allow staged migration.
HISTORY
This module was originally written by Mark Morgan
<makk384@gmail.com>
, with some bugfix patches by Christian Walde.It was rewritten for Moose 2.0 by Karen Etheridge
<ether@cpan.org>
, drawing heavily on MooseX::StrictConstructor.ACKNOWLEDGEMENTS
Thanks to the folks from the Moose mailing list and IRC channels for helping me find my way around some of the Moose bits I didn't know of before writing this module.
SUPPORT
Bugs may be submitted through the RT bug tracker (or bug-MooseX-SlurpyConstructor@rt.cpan.org).
There is also a mailing list available for users of this distribution, at http://lists.perl.org/list/moose.html.
There is also an irc channel available for users of this distribution, at
#moose
onirc.perl.org
.AUTHORS
Mark Morgan <makk384@gmail.com>
Karen Etheridge <ether@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Karen Etheridge.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install MooseX::SlurpyConstructor, copy and paste the appropriate command in to your terminal.
cpanm MooseX::SlurpyConstructor
perl -MCPAN -e shell install MooseX::SlurpyConstructor
For more information on module installation, please visit the detailed CPAN module installation guide.