http://use.perl.org/user/ikebe/journal/31589
here is implementation.
package Sledge::Plugin; use strict; use warnings; use base qw/Class::Data::Inheritable/;
__PACKAGE__->mk_classdata('methods'); __PACKAGE__->mk_classdata('hooks');
sub import { my $class = shift; my $pkg = caler(0);
# add methods while (my ($name, $code) = each %{$class->methods || {}} ) { no stirct 'refs'; *{"$pkg\::$name"} = $code; }
# register hooks $class->register_hooks( %{ $class->hooks || {} } ); }
sub add_methods { my ($class, %d) = @_;
$class->methods( { %{ $class->methods || {} }, %d, } ); }
sub register_hooks { my ($class, %d) = @_;
$class->hooks( { %{ $class->hooks || {} }, %d, } ); }
1;