MooseX::NestedAttributesConstructor - Create attributes from a nested data structure
package Address use Moose; has street => ( is => 'rw' ); has city => ( is => 'rw' ); # ... package Person; use Moose; use MooseX::NestedAttributesConstructor has name => ( is => 'rw' ); has addresses => ( is => 'rw', isa => 'ArrayRef[Address]', traits => ['NestedAttribute'] ); # ... package main; use Person; my $p = Person->new(name => 'sshaw', addresses => [ { city => 'LA' }, { city => 'Da Bay' }, { city => 'Even São José' } ]); say $_->city for @{$p->addresses};
This module sets attributes from a nested data structure passed your object's constructor. The appropriate types will be created, just add the NestedAttrubute trait to attributes with a custom or parameterized type.
NestedAttrubute
Nested attributes are turned into objects after BUILDARGS is called.
BUILDARGS
Skye Shaw (sshaw AT lucas.cis.temple.edu)
MooseX::StrictConstructor
Copyright (c) 2012 Skye Shaw.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::NestedAttributesConstructor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::NestedAttributesConstructor
CPAN shell
perl -MCPAN -e shell install MooseX::NestedAttributesConstructor
For more information on module installation, please visit the detailed CPAN module installation guide.