NAME
Class::Accessor::WithDefault - Set Default Value Implement on Class::Accessor
SYNOPSIS
use Class::Accessor::WithDefault;
__PACKAGE__->mk_accessors(qw/a b/,{c => 'default value'});
....
#..->new();
print $object->c; #default value
DESCRIPTION
Class::Accessor is great, except for some inconvenience in setting the default value for the fields. Overrding the new method is some kind of inconvenient too.
This module allows you to set the default value for all the generated accessors by passing a hashref to the method.
NOTE: Don't use
$object->get("c");
to get the default value, this won't work.
SEE ALSO
Class::Accessor
AUTHOR
Woosely.Xu
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Woosley.Xu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.