NAME

Class::Accessor::WithDefault - Set Default Value Implement on Class::Accessor

SYNOPSIS

use Class::Accessor::WithDefault;
__PACKAGE__->mk_accessors(qw/foo bar/,{a => '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

__PACKAGE__->mk_accessors(qw/foo bar/,{foo=>'default'});

It won't set "defalt" to foo

NOTE: Don't use get to get the default value, it 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.