Object::Meta::Plugin::Useful::Meta - A subclass of Object::Meta::Plugin::Useful and Object::Meta::Plugin::Host, base class for hosts which are plugins.
my $host = Object::Meta::Plugin::Host->new(); my $plugin = Object::Meta::Plugin::Useful::Meta::new(); $plugin->plug(MyPlug->new()); # of course, there's no point if # this isn't more interesting $host->plugin($plugin);
This is an Object::Meta::Plugin::Host and more. It provides the necessary methods to treat a host as a plugin. It is not the most elegant solution, see CAVEATS.
CAVEATS
Returns the methods of the host it subclasses.
Somewhat defies the purpose of plugging things in. It is possible (and even tested for, look at "lib/OMPTest.pm" in t) to plug a plugin into a host, and have that plugin provide plugin capabilities. Such an implementation would look like this:
package SuperPlugin; use strict; use warnings; use base 'Object::Meta::Plugin::Useful::Generic'; sub new { my $pkg = shift; my $self = $pkg->SUPER::new(@_); $self->export(/init exports/); }; sub init { my $self = shift; if ($self->can("super")){ # if we're part of a context, we're called from a host unshift @_, $self->super; &init; # switch self, and rerun } else { $self->SUPER::init(@_); # goto the superclass (Object::Meta::Plugin::Useful::Generic) init. } } sub exports { # if $self->can(super) return self->super->methods, whatever. Otherwise, export self as a plugin. my $self = shift; if ($self->can("super")){ # plugged in keys %{ $self->super->methods }; # return the method names for the host } else { $self->SUPER::exports(@_); # Object::Meta::Plugin::Useful::Generic::exports } }
Nada.
Nothing right now.
Copyright 2003 Yuval Kogman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Yuval Kogman <nothingmuch@woobling.org>
Object::Meta::Plugin, Object::Meta::Plugin::Useful, Object::Meta::Plugin::Useful::Generic, Object::Meta::Plugin::Useful::Greedy.
To install Object::Meta::Plugin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Meta::Plugin
CPAN shell
perl -MCPAN -e shell install Object::Meta::Plugin
For more information on module installation, please visit the detailed CPAN module installation guide.