Take me over?
NAME
Object::Meta::Plugin::ExportList - an implementation of a very simple, string only export list.
SYNOPSIS
# the proper way
my $plugin = GoodPlugin->new();
$host->plug($plugin);
package GoodPlugin;
# ...
sub exports {
qw/some methods/;
}
sub init {
my $self = shift;
return Object::Meta::Plugin::ExportList->new($self};
}
# or if you prefer.... *drum roll*
# the naughty way
my $plugin = BadPlugin->new(); # doesn't need to be a plugin per se, since
# it's not verified by plug(). All it needs
# is to have a working can(). the export
# list is responsible for the rest.
# in short, this way init() needn't be defined.
my $export = Object::Meta::Plugin::ExportList->new($plugin, qw/foo bar/);
$host->register($export);
DESCRIPTION
An export list is an object a plugin hands over to a host, stating what it is going to give it. This is a very basic implementation, providing only the bare minimum methods needed to register a plugin. Unregistering one requires even less.
METHODS
- new PLUGIN [ INFO ] [ METHODS ... ]
-
Creates a new export list object. If it is a reference, it will be assumed that the second argument is an info object. Provided that is the case, no info object will be created, and the argued one will be used in place. Any remaining arguments will be method names to be exported. If none are specified, the return value from the plugin's
exports
method is used. - list
-
Returns a list of exported method names.
- plugin
-
Returns the reference to the plugin object it represents.
- exists METHODS ...
-
In scalar context will return truth if the first argument is a method that exists in the export list. In list context, it will return the method names given in @_, with the inexistent ones excluded.
- merge EXPORTLIST
-
Performs an or with the methods of the argued export list.
- unmerge EXPORTLIST
-
Performs an and of the complement of the argued export list.
- info [ INFO ]
-
Stores meta information regarding the plugin it represents. It's stored in the export list because the export list is what you use to communicate with the host.
Currently only the style field is defined, which will effect the kind of context shim that is created. The default is the most naive, but also the least efficient - the tied context.
Object::Meta::Plugin::ExportList::Info
This is just a hash, basically. It has an autoloader which will fetch a hash key by the method name with no arguments, or set the value to the first argument if it's there.
Deletion is not supported.
Known attributes
- style
-
This attribute can have one of two values, either tied or explicit. It tells the context shims how to behave. On tied, the default, the shim will have it's structure be a tied one, representing the structure of the plugin. Currently hash, array and scalar refs are supported. Filehandle tie support is a little bit hairy at the moment. The explicit style gives the standard shim structure to the plugin. To gain access to it's structures a plugin will then need to call the method
self
on the shim, as documented in Object::Meta::Plugin::Host. explicit is probably much more efficient, but is less coder friendly. The value force-tied is honored by Object::Meta::Plugin::Host::Context, and will not die onplug
time if you try to use it on a plugin whose structure is already tied.Again, see Object::Meta::Plugin::Host for documentation of the way styles change things.
CAVEATS
Relies on the plugin implementation to provide a non-mandatory extension - the
exports
method. This method is available in all the Object::Meta::Plugin::Useful variants, and since Object::Meta::Plugin is not usable on it's own this is probably ok.
BUGS
Not that I know of, for the while being at least.
COPYRIGHT & LICENSE
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.
AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
SEE ALSO
Object::Meta::Plugin, Object::Meta::Plugin::Useful, Object::Meta::Plugin::Host