logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

MooX::Thunking - Allow Moo attributes to be "thunked"

Author

       Ed J

Description

       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.

       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.

Licence

       The same terms as Perl itself.

perl v5.36.0                                       2022-11-27                                MooX::Thunking(3pm)

Name

       MooX::Thunking - Allow Moo attributes to be "thunked"

Synopsis

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

See Also