Anansi::Component - A base module definition for related processes that are managed.
package Anansi::ComponentManagerExample::ComponentExample; use base qw(Anansi::Component); sub validate { return 1; } sub doSomething { my ($self, $channel, %parameters) = @_; } Anansi::Component::addChannel( 'Anansi::ComponentManagerExample::ComponentExample', 'VALIDATE_AS_APPROPRIATE' => Anansi::ComponentManagerExample::ComponentExample->validate ); Anansi::Component::addChannel( 'Anansi::ComponentManagerExample::ComponentExample', 'SOME_COMPONENT_CHANNEL' => Anansi::ComponentManagerExample::ComponentExample->doSomething ); 1; package Anansi::ComponentManagerExample; use base qw(Anansi::ComponentManager); sub doSomethingElse { my ($self, $channel, %parameters) = @_; } Anansi::ComponentManager::addChannel( 'Anansi::ComponentManagerExample', 'SOME_MANAGER_CHANNEL' => Anansi::ComponentManagerExample->doSomethingElse ); 1; package main; use Anansi::ComponentManagerExample; my $object = Anansi::ComponentManagerExample->new(); my $component = $object->addComponent(); my $result = $object->channel( $component, 'SOME_COMPONENT_CHANNEL', someParameter => 'some data', ); 1;
This is a base module definition for related functionality modules. This module provides the mechanism to be handled by a Anansi::ComponentManager module. In order to simplify the recognition and management of related component modules, each component is required to have the same base namespace as it's manager. Uses Anansi::Actor.
See Anansi::Class for details. A parent module of Anansi::Component.
See Anansi::Class::DESTROY for details.
See Anansi::Class::finalise for details. A virtual method.
See Anansi::Class::implicate for details. A virtual method.
See Anansi::Class::import for details.
See Anansi::Class::initialise for details. A virtual method.
See Anansi::Class::new for details.
See Anansi::Class::old for details.
See Anansi::Class::used for details.
See Anansi::Class::uses for details.
See Anansi::Class::using for details.
if(1 == Anansi::Component->addChannel( someChannel => 'Some::subroutine', anotherChannel => Some::subroutine, yetAnotherChannel => $AN_OBJECT->someSubroutine, etcChannel => sub { my $self = shift(@_); } )); if(1 == $OBJECT->addChannel( someChannel => 'Some::subroutine', anotherChannel => Some::subroutine, yetAnotherChannel => $AN_OBJECT->someSubroutine, etcChannel => sub { my $self = shift(@_); } ));
An object or string of this namespace.
Named parameters where the key is the name of the channel and the value is either a namespace string or code reference to an existing subroutine or an anonymous subroutine definition.
Defines the responding subroutine for the named component channels.
Anansi::Component->channel('Anansi::Component::Example'); $OBJECT->channel(); Anansi::Component->channel( 'Anansi::Component::Example', 'someChannel', someParameter => 'something' ); $OBJECT->channel( 'someChannel', someParameter => 'something' );
Has a floating first parameter, dependant on how the subroutine is called.
The name of the channel to pass control to.
The parameters to pass to the channel.
Either returns an array of the available channels or passes the supplied parameters to the named channel. Returns undef on error.
my $managers = Anansi::Component->componentManagers(); my $managers = Anansi::Component::componentManagers('Anansi::ComponentManagerExample::ComponentExample'); my $managers = $OBJECT->componentManagers();
Either returns an ARRAY of all of the available component managers or an ARRAY containing the current component's manager.
if(1 == Anansi::Component::removeChannel( 'Anansi::ComponentManagerExample::ComponentExample', 'someChannel', 'anotherChannel', 'yetAnotherChannel', 'etcChannel' )); if(1 == $OBJECT->removeChannel( 'someChannel', 'anotherChannel', 'yetAnotherChannel', 'etcChannel' ));
A string or array of strings containing the name of a channel.
Undefines the responding subroutine for the named component channels. Returns 1 (one) on success or 0 (zero) on failure.
This module is designed to make it simple, easy and quite fast to code your design in perl. If for any reason you feel that it doesn't achieve these goals then please let me know. I am here to help. All constructive criticisms are also welcomed.
Kevin Treleaven <kevin AT treleaven DOT net>
To install Anansi::Component, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Anansi::Component
CPAN shell
perl -MCPAN -e shell install Anansi::Component
For more information on module installation, please visit the detailed CPAN module installation guide.