MooX::Thunking - Allow Moo attributes to be "thunked"
package Thunking; use Moo; use MooX::Thunking; use Types::TypeTiny -all; use Types::Standard -all; has children => ( is => 'thunked', isa => ArrayRef[InstanceOf['Thunking']], required => 1, ); package main; my $obj; $obj = Thunking->new(children => sub { [$obj] });
This is a Moo extension. It allows another value for the is parameter to "has" in Moo: "thunked". If used, this will allow you to transparently provide either a real value for the attribute, or a "CodeLike" in Types::TypeTiny that when called will return such a real value.
is
Note that in earlier versions of this module (up to 0.06), any isa had to pass a CodeLike. This is now taken care of by this module. It will continue to do the right thing if no isa is supplied.
isa
CodeLike
Ed J
The same terms as Perl itself.
To install MooX::Thunking, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooX::Thunking
CPAN shell
perl -MCPAN -e shell install MooX::Thunking
For more information on module installation, please visit the detailed CPAN module installation guide.