The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Anansi::Component - A base module definition for related processes that are managed.

SYNOPSIS

    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;

DESCRIPTION

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.

METHODS

Anansi::Class

See Anansi::Class for details. A parent module of Anansi::Component.

DESTROY

See Anansi::Class::DESTROY for details.

finalise

See Anansi::Class::finalise for details. A virtual method.

implicate

See Anansi::Class::implicate for details. A virtual method.

import

See Anansi::Class::import for details.

initialise

See Anansi::Class::initialise for details. A virtual method.

new

See Anansi::Class::new for details.

old

See Anansi::Class::old for details.

used

See Anansi::Class::used for details.

uses

See Anansi::Class::uses for details.

using

See Anansi::Class::using for details.

addChannel

    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(@_);
        }
    ));
self (Blessed Hash or String, Required)

An object or string of this namespace.

parameters (Hash, Optional)

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.

channel

    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.

self (Blessed Hash or String, Required)

An object or string of this namespace.

channel (String, Optional)

The name of the channel to pass control to.

parameters (Scalar or Array or Hash, Optional)

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.

componentManagers

    my $managers = Anansi::Component->componentManagers();

    my $managers = Anansi::Component::componentManagers('Anansi::ComponentManagerExample::ComponentExample');

    my $managers = $OBJECT->componentManagers();
self (Blessed Hash or String, Required)

An object or string of this namespace.

Either returns an ARRAY of all of the available component managers or an ARRAY containing the current component's manager.

removeChannel

    if(1 == Anansi::Component::removeChannel(
        'Anansi::ComponentManagerExample::ComponentExample',
        'someChannel',
        'anotherChannel',
        'yetAnotherChannel',
        'etcChannel'
    ));

    if(1 == $OBJECT->removeChannel(
        'someChannel',
        'anotherChannel',
        'yetAnotherChannel',
        'etcChannel'
    ));
self (Blessed Hash or String, Required)

An object or string of this namespace.

parameters (String or Array, Required)

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.

NOTES

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.

AUTHOR

Kevin Treleaven <kevin AT treleaven DOT net>