Skip to content

sshaw/MooseX-NestedAttributesConstructor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

MooseX::NestedAttributesConstructor - Create attributes from a nested data structure

OVERVIEW

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};

DESCRIPTION

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.

Nested attributes are turned into objects after BUILDARGS is called.

AUTHOR

Skye Shaw (skye.shaw AT gmail.com)

SEE ALSO

MooseX::StrictConstructor, MooseX::Types

COPYRIGHT

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.

About

Create attributes from a nested data structure

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages