Kevin Treleaven > Anansi-Library > Anansi::Library

Download:
Anansi-Library-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Anansi::Library - A base module definition for object functionality extension.

SYNOPSIS ^

    # Note: As 'base' needs a module file, this package must be declared in 'LibraryExample.pm'.
    package LibraryExample;

    use base qw(Anansi::Library);

    sub libraryExample {
        my ($self, %parameters) = @_;
    }

    1;

    # Note: This package should be declared in 'ClassExample.pm'.
    package ClassExample;

    use base qw(Anansi::Class LibraryExample);

    sub classExample {
        my ($self, %parameters) = @_;
        $self->libraryExample();
        $self->LibraryExample::libraryExample();
    }

    1;

DESCRIPTION ^

This is a base module definition that manages the functionality extension of module object instances.

METHODS ^

abstractClosure

    my $CLOSURE = Anansi::Library->abstractClosure(
        'Some::Namespace',
        'someKey' => 'some data',
        'anotherKey' => 'Subroutine::Namespace',
        'yetAnotherKey' => Namespace::someSubroutine,
    );
    $CLOSURE->anotherKey();
    $CLOSURE->yetAnotherKey();

    sub Subroutine::Namespace {
        my ($self, $closure, %parameters) = @_;
        my $abc = ${$closure}{abc} || 'something';
        ${$closure}{def} = 'anything';
    }
class (Blessed Hash or String, Required)

Either an object of this namespace or this module's namespace.

abstract (String, Required)

The namespace to associate with the closure's encapsulating object.

parameters (Hash, Optional)

Named parameters where either the key is the name of a variable stored within the closure and the value is it's data or when the value is a subroutine the key is the name of a generated method of the closure's encapsulating object that runs the subroutine and passes it a reference to the closure.

Creates both an anonymous hash to act as a closure variable and a blessed object as the closure's encapsulating accessor. Supplied data is either stored within the closure using the key as the name or in the case of a subroutine, accessed by an auto-generated method of that name. Closure is achieved by passing a reference to the anonymous hash to the supplied subroutines via the auto-generated methods.

abstractObject

    my $OBJECT = Anansi::Library->abstractObject(
        'Some::Namespace',
        'someKey' => 'some data',
        'anotherKey' => 'Subroutine::Namespace',
        'yetAnotherKey' => Namespace::someSubroutine,
    );
    $OBJECT->anotherKey();
    $OBJECT->yetAnotherKey();

    sub Subroutine::Namespace {
        my ($self, %parameters) = @_;
        my $abc = $self->{abc} || 'something';
        $self->{def} = 'anything';
    }
class (Blessed Hash or String, Required)

Either an object of this namespace or this module's namespace.

abstract (String, Required)

The namespace to associate with the object.

parameters (Hash, Required)

Named parameters where either the key is the name of a variable stored within the object and the value is it's data or when the value is a subroutine the key is the name of a namespace method.

Creates a blessed object. Supplied data is either stored within the object or in the case of a subroutine as a namespace method of that name.

hasAncestor

    my $MODULE_ARRAY = $OBJECT->hasAncestor();
    if(defined($MODULE_ARRAY));

    if(1 == $OBJECT->hasAncestor(
        'Some::Module',
        'Another::Module',
        'Etc'
    ));
self (Blessed Hash, Required)

An object of this namespace.

name (Array or String, Optional)

A namespace or an array of namespaces.

Either returns an array of all the loaded modules that the object inherits from or whether the object inherits from all of the specified loaded modules with a 1 (one) for yes and 0 (zero) for no.

hasDescendant

    my $MODULE_ARRAY = $OBJECT->hasDescendant();
    if(defined($MODULE_ARRAY));

    if(1 == $OBJECT->hasDescendant('Some::Module', 'Another::Module', 'Etc'));
self (Blessed Hash, Required)

An object of this namespace.

name (Array or String, Optional)

A namespace or an array of namespaces.

Either returns an array of all the loaded modules that the object is inherited from or whether the object is inherited from all of the specified loaded modules with a 1 (one) for yes and 0 (zero) for no.

hasLoaded

    my $MODULE_ARRAY = $OBJECT->hasLoaded();
    if(defined($MODULE_ARRAY));

    my $MODULE_ARRAY = Anansi::Library->hasLoaded();
    if(defined($MODULE_ARRAY));

    if(1 == $OBJECT->hasLoaded(
        'Some::Module',
        'Another::Module',
        'Etc'
    ));

    if(1 == Anansi::Library->hasLoaded(
        'Some::Module',
        'Another::Module',
        'Etc'
    ));
self (Blessed Hash, Required)

An object of this namespace.

name (Array or String, Optional)

A namespace or an array of namespaces.

Either returns an array of all the loaded modules or whether all of the specified modules have been loaded with a 1 (one) for yes and 0 (zero) for no.

hasSubroutine

    my $SUBROUTINE_ARRAY = $OBJECT->hasSubroutine();
    if(defined($SUBROUTINE_ARRAY));

    if(1 == $OBJECT->hasSubroutine(
        'someSubroutine',
        'anotherSubroutine',
        'etc'
    ));
self (Blessed Hash, Required)

An object of this namespace.

name (Array or String, Optional)

A namespace or an array of namespaces.

Either returns an array of all the subroutines in the loaded module or whether the loaded module has all of the specified subroutines with a 1 (one) for yes and 0 (zero) for no.

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>

syntax highlighting: