Attribute::Handlers and pluggability

pemungkah on 2006-05-16T22:47:37

With chromatic's entry yesterday and a fair amount of experimentation and glob madness, I've finally gotten an elegant way to handle getting rid of the monkey code in my pluggability framework, which will be part of the "Designing for Pluggability" talk at YAPC.

package Vacuum::Plugin::Screamer;
use base qw(Plugin::Base);
no strict;

sub foo :PluggedMethod { print "RUNNING!!!!!\n"; }

sub volume :Option(=i); sub vocal_range :Slot;

1;
Here we have defined a plugin method that will automatically be accessible to the parent (Vacuum::Pluggable), a command-line option definition (with automatic creation of an accessor nethod for it), and a slot to be added to the parent object (with an automatically-generated accessor as well).

Still to go: prehooks and posthooks, and the generalization of the pluggable base class, but it's all going very well. This is sufficiently advanced technology with a vengeance. Thanks!