Class::Accessor::Fast::WithBuilder - Class::Accessor::Fast with lazy defaults
0.0101
This module will require builders for each attribute defined. This means that adding attributes with this module, is something like this code from Moose:
has age => ( is => "ro", # or rw lazy => 1, builder => "_build_age", );
NOTE: All builders will be called as late as possible.
package Foo; use base qw(Class::Accessor::Fast::WithBuilder); Foo->mk_accessors(qw( name age )); sub _build_name { $_[0]->_croak("'name' attribute cannot be built!") } sub _build_age { 0 } print Foo->new->name; # BOOM! print Foo->new->age; # Will print "0" print Foo->new({ age => 123 })->age; # Will print "123"
See "make_accessor" in Class::Accessor
See "make_ro_accessor" in Class::Accessor
This is not implemented. (See "make_wo_accessor" in Class::Accessor)
Jan Henning Thorsen jhthorsen at cpan.org
jhthorsen at cpan.org
To install Class::Accessor::Fast::WithBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Accessor::Fast::WithBuilder
CPAN shell
perl -MCPAN -e shell install Class::Accessor::Fast::WithBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.