NAME
Anansi::Singleton - A base module definition where only a single object instance is allowed.
SYNOPSIS
package Anansi::Example;
use base qw(Anansi::Singleton);
sub finalise {
my ($self, %parameters) = @_;
}
sub fixate {
my ($self, %parameters) = @_;
}
sub initialise {
my ($self, %parameters) = @_;
}
sub reinitialise {
my ($self, %parameters) = @_;
}
1;
DESCRIPTION
This is a base module definition that manages the creation and destruction of module object instances that are not repeatable including embedded objects and ensures that destruction can only occur when all duplicate object instances are no longer used. Uses Anansi::Class, Anansi::ObjectManager and base.
METHODS
Anansi::Class
-
(Anansi::Class) A parent module.
DESTROY
-
(Anansi::Class::DESTROY) Overridden by Anansi::Singleton::DESTROY.
finalise
-
(Anansi::Class::finalise) A virtual method.
implicate
-
(Anansi::Class::implicate) A virtual method.
import
initialise
-
(Anansi::Class::initialise) A virtual method.
new
-
(Anansi::Class::new) Overridden by Anansi::Singleton::new.
old
used
uses
DESTROY
Overrides Anansi::Class::DESTROY. Performs module object instance clean-up actions. Either calls the fixate method prior to dereferencing an instance of the object where more than one instance exists or the finalise method prior to dereferencing the last instance. Indirectly called by the perl interpreter.
fixate
$OBJECT->fixate();
$OBJECT->SUPER::fixate();
- self (Blessed Hash, Required)
-
An object of this namespace.
- parameters (Hash, Optional)
-
Named parameters.
A virtual method. Called just prior to module instance object destruction where there are multiple instances of the object remaining.
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.
Overrides Anansi::Class::new. Instantiates or reinstantiates an object instance of a module. Either calls the initialise method with the supplied parameters after the object is first instantiated or the reinitialise method after subsequent instantiations.
reinitialise
$OBJECT->reinitialise();
$OBJECT->SUPER::reinitialise();
- self (Blessed Hash, Required)
-
An object of this namespace.
- parameters (Hash, Optional)
-
Named parameters.
A virtual method. Called just after module instance object recreation. Intended to be overridden by an extending module.
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>