Krang::MethodMaker - extended version of Class::MethodMaker
# create a readonly foo_id() accessor and standard accessor/mutators
# title() and url(). Create standard accessor/mutators itchy() and
# scratchy() that trigger calls to _notify() when set.
use Krang::ClassLoader MethodMaker =>
get => ['foo_id'],
get_set => ['title', 'url'],
get_set_with_notify => { method => '_notify',
attr => ['itchy', 'scratchy'] };
# catch changes to itchy and scratchy
sub _notify {
my ($self, $which, $old, $new) = @_;
# ...
}
This class extends Class::MethodMaker for use by Krang. All the normal Class::MethodMaker generators are available from Krang::MethodMaker, with a few changes.
When we identify repeated code patterns we should consider adding a method generator to this class.
foo() and foo_clear(), Krang's
get_set takes none of the ``flavor'' options (-java, etc) and always
behaves as though -noclear were used.
Also, the code generated is faster than the default Class::MethodMaker code since it doesn't use lexicals.
Takes a list of hashes with two keys - method and attr.