NAME
MooseX::Attribute::LazyInflator - Deflates and inflates Moose attributes to and from a string
VERSION
version 2.0.1
SYNOPSIS
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;
DESCRIPTION
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.
This module will defer object inflation and constraint validation until it is first accessed. Furthermore the advantages of inflate
apply as well.
SEE ALSO
- MooseX::Attribute::LazyInflator::Role::Class
- MooseX::Attribute::LazyInflator::Meta::Role::Method::Accessor>
- MooseX::Attribute::LazyInflator::Meta::Role::Method::Constructor
- "inflate" in MooseX::Attribute::Deflator
AUTHOR
Moritz Onken
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License