Kevin Treleaven > Anansi-Class-0.09 > Anansi::Class

Download:
Anansi-Class-0.09.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.09   Source  

NAME ^

Anansi::Class - A base module definition

SYNOPSIS ^

    package Anansi::Example;

    use base qw(Anansi::Class);

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

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

    1;

    package main;

    use Anansi::Example;

    my $object = Anansi::Example->new();

    1;

DESCRIPTION ^

This is a base module definition that manages the creation and destruction of module object instances including embedded objects and ensures that destruction can only occur when an object is no longer used. Makes use of Anansi::ObjectManager.

METHODS ^

DESTROY

self (Blessed Hash, Required)

An object of this namespace.

Performs module object instance clean-up actions. Calls the finalise method prior to dereferencing the object. Indirectly called by the perl interpreter.

finalise

    $OBJECT->finalise();

    $OBJECT->SUPER::finalise();
self (Blessed Hash, Required)

An object of this namespace.

A virtual method. Called just prior to module instance object destruction.

implicate

    sub implicate {
        my ($self, $caller, $parameter) = @_;
        if('EXAMPLE_VARIABLE' eq $parameter) {
            return \EXAMPLE_VARIABLE;
        }
        try {
            return $self->SUPER::implicate($caller, $parameter);
        }
        return if($@);
    }
self (Blessed Hash, Required)

An object of this namespace.

caller (Array, Required)

An array containing the package, file name and line number of the caller.

parameter (String, Required)

A string containing the name to import.

A virtual method. Performs one module instance name import. Called for each name to import.

import

    use Anansi::Example qw(EXAMPLE_VARIABLE);
self (Blessed Hash, Required)

An object of this namespace.

parameters (Array, Optional)

An array containing all of the names to import.

Performs all required module name imports. Indirectly called via an extending module.

initialise

    $OBJECT->initialise();

    $OBJECT->SUPER::initialise();
self (Blessed Hash, Required)

An object of this namespace.

parameters (Hash, Optional)

Named parameters that were supplied to the new method.

A virtual method. Called just after module instance object creation.

new

    my $object = Anansi::Example->new();

    my $object = Anansi::Example->new(
       SETTING => 'example',
    );
class (Blessed Hash or String, Required)

Either an object or a string of this namespace.

parameters (Hash, Optional)

Named parameters.

Instantiates an object instance of a module. Calls the initialise module with the supplied parameters after the object is instantiated. Indirectly called via an extending module through inheritance.

old

    $object->old();
self (Blessed Hash, Required)

An object of this namespace.

parameters (Hash, Optional)

Named parameters.

Enables a module instance object to be externally destroyed.

used

    $object->used('EXAMPLE');
self (Blessed Hash, Required)

An object of this namespace.

parameters (Array, Optional)

An array of strings containing the names of blessed objects currently in use by this object.

Releases a module instance object to enable it to be destroyed.

uses

    $object->uses(
        EXAMPLE => $example,
    );

    $object->uses(
        EXAMPLE => 'Anansi::Example',
    );
    $object->{EXAMPLE}->doSomething();
self (Blessed Hash, Required)

An object of this namespace.

parameters (Hash, Optional)

A hash containing keys that represent the name to associate with the string namespace or object within the associated values.

Binds module instance objects to the current object to ensure that the objects are not prematurely destroyed. Adds the parameters to the object namespace.

using

    my $names = $object->using();
    foreach my $name (@{$names}) {
        $object->{$name}->doSomething();
    }

    $object->using('EXAMPLE')->doSomething();

    if(1 == $object->using(
        'EXAMPLE',
        'ANOTHER',
    ));
self (Blessed Hash, Required)

An object of this namespace.

parameters (Array or String, Optional)

A string or an array of strings containing the names of blessed objects currently in use by this object.

Either returns an array of strings containing the names of the blessed objects currently in use by this object or the blessed object represented by the single specified name or whether the specified names represent blessed objects 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: