Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sshaw/moosex-nestedattributesconstructor
Create attributes from a nested data structure
https://github.com/sshaw/moosex-nestedattributesconstructor
attributes moose moosex parameters perl
Last synced: 9 days ago
JSON representation
Create attributes from a nested data structure
- Host: GitHub
- URL: https://github.com/sshaw/moosex-nestedattributesconstructor
- Owner: sshaw
- Created: 2012-12-25T20:17:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-22T00:22:35.000Z (over 11 years ago)
- Last Synced: 2024-12-17T00:46:14.229Z (12 days ago)
- Topics: attributes, moose, moosex, parameters, perl
- Language: Perl
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
Awesome Lists containing this project
README
=pod
=encoding utf8
=head1 NAME
MooseX::NestedAttributesConstructor - Create attributes from a nested data structure
=head1 OVERVIEW
package Address
use Moose;has street => ( is => 'rw' );
has city => ( is => 'rw' );
# ...package Person;
use Moose;
use MooseX::NestedAttributesConstructorhas 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};
=head1 DESCRIPTION
This module sets attributes from a nested data structure passed your object's constructor.
The appropriate types will be created, just add the C trait to attributes with
a custom or parameterized type.Nested attributes are turned into objects after C is called.
=head1 AUTHOR
Skye Shaw (skye.shaw AT gmail.com)
=head1 SEE ALSO
L, L
=head1 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.