Class::Component::Plugin - plugin base for pluggable component framework
Your plugins should succeed to Class::Component::Plugin by your name space, and use it.
package MyClass::Plugin; use strict; use warnings; use base 'Class::Component::Plugin'; 1;
for instance, the init phase is rewritten.
package MyClass::Plugin; use strict; use warnings; use base 'Class::Component::Plugin'; __PACKAGE__->mk_accessors(qw/ base_config /); sub init { my($self, $c) = @_; $self->base_config($self->config); $self->config($self->config->{config}); } 1; package MyClass::Plugin::Hello; use strict; use warnings; use base 'MyClass::Plugin'; sub hello :Method { my($self, $context, $args) = @_; 'hello' } sub hello_hook :Hook('hello') { my($self, $context, $args) = @_; 'hook hello' }
can use alias method name
sub foo :Method('bar') {} $self->call('bar'); # call foo method
default hook name is method name if undefined Hook name
sub defaulthook :Hook {} $self->run_hook( 'defaulthook' );
init phase your plugins
1 = using attribute detect cache 0 = not use cache
attribute name space detector
register_method is automatically done.
register_hook is automatically done.
Kazuhiro Osawa <ko@yappo.ne.jp>
Class::Component
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::Component, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Component
CPAN shell
perl -MCPAN -e shell install Class::Component
For more information on module installation, please visit the detailed CPAN module installation guide.