The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::SlurpyConstructor - Assign all unknown arguments to attribute in object constructor.

SYNOPSIS

    package ASDF;

    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.

When composing a class, an error will be raised if more than one attribute of the class is marked as 'slurpy'. Also, at object instatiation time, an error will be raised if the class being instantiated uses this one, but does not declare a slurpy attribute.

SEE ALSO

MooseX::StrictConstructor

The opposite of this module, making constructors die on unknown arguments. Note that if both of these are used together, SlurpyConstructor will take precedence and strict constructor explosions will never occour.

AUTHOR

Mark Morgan <makk384@gmail.com>

Thanks to the folks from 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.

BUGS

As usual, send bugs or feature requests to bug-moosex-slurpyconstructor@rt.cpan.org or through web interface http://rt.cpan.org.

COPYRIGHT & LICENSE

Copyright 2009 Mark Morgan, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.