
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.

Returns the methods of the host it subclasses.

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.