MooseX::Attribute::LazyInflator - Lazy inflate attributes on access for better performance
version 2.2.2
package Test; use Moose; use MooseX::Attribute::LazyInflator; # Load default deflators and inflators use MooseX::Attribute::Deflator::Moose; has hash => ( is => 'rw', isa => 'HashRef', traits => ['LazyInflator'] ); package main; my $obj = Test->new( hash => '{"foo":"bar"}' ); # Attribute 'hash' is being inflated to a HashRef on access $obj->hash;
Using coerce will inflate an object on construction even if it is not needed. This has the advantage, that type constraints are being called but on the other hand it is rather slow.
coerce
This module will defer object inflation and constraint validation until it is first accessed. Furthermore the advantages of inflate apply as well.
inflate
Moritz Onken
This software is Copyright (c) 2012 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
To install MooseX::Attribute::Deflator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Attribute::Deflator
CPAN shell
perl -MCPAN -e shell install MooseX::Attribute::Deflator
For more information on module installation, please visit the detailed CPAN module installation guide.