MooseX::AttributeInflate - Auto-inflate your Moose attribute objects
Version 0.03
Lazily constructs ("inflates") an object attribute, optionally using constant parameters.
package MyClass; use MooseX::AttributeInflate; has_inflated 'helper' => ( is => 'ro', isa => 'MyHelper' ); # OR, explicitly has 'helper' => ( is => 'ro', isa => 'MyHelper', traits => [qw/Inflated/], inflate_args => [], inflate_method => 'new', ); my $obj = MyClass->new(); $obj->helper->help();
For each attribute defined with "has_inflated", this module overrides the default for that attribute, calling instead that attribute's type's constructor. The construction is done lazily unless overriden with lazy => 0.
default
lazy => 0
See "has_inflated" for options and more detail.
Construction only works with objects; an exception will be thrown if the isa type of this attribute is not a decendant of Object (this includes ArrayRef and HashRef types).
isa
Object
ArrayRef
HashRef
Alternatively, you may use the attribute trait Inflated to compose an attribute with other attribute trais.
Inflated
Just like Moose's has, but applies the attribute trait Inflated and defaults lazy to be on. See "EXPORTED FUNCTIONS" in Moose for more detail on has.
has
lazy
If lazy_build is defined, the canonical build method (e.g. _build_helper) IS NOT called. Otherwise, lazy_build works as usual, setting required and installing a clearer and predicate.
lazy_build
_build_helper
required
Additional options:
Defaults on, but can be turned off with lazy => 0.
Just like Moose's lazy_build, but does not call the canonical builder method (e.g. _build_$name).
_build_$name
The name of the constructor to use. Defaults to 'new'.
The arguments to pass to the constructor. Defaults to an empty list.
MooseX::CurriedHandles - combine with this module for auto-inflating moose curry!
http://github.com/stash/moosex-attributeinflate/ - Github repository
Stash <jstash+cpan@gmail.com>
Please report any bugs or feature requests to bug-moosex-attrinflate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-AttributeInflate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-moosex-attrinflate at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc MooseX::AttributeInflate
You can also look for information at:
#moose on irc.perl.org
#moose
irc://irc.perl.org#moose
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-AttributeInflate
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/MooseX-AttributeInflate
CPAN Ratings
http://cpanratings.perl.org/d/MooseX-AttributeInflate
Search CPAN
http://search.cpan.org/dist/MooseX-AttributeInflate
konobi for Meta-advice and CPAN help
konobi
perigrin, doy, Sartak and other #moose folks for suggestions & patches.
perigrin
doy
Sartak
Copyright 2009 Jeremy Stashewsky
Copyright 2009 Socialtext Inc., all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::AttributeInflate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::AttributeInflate
CPAN shell
perl -MCPAN -e shell install MooseX::AttributeInflate
For more information on module installation, please visit the detailed CPAN module installation guide.