Anansi::Singleton - A base module definition where only a single object instance is allowed.
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; package main; use Anansi::Example; my $object = Anansi::Example->new(); 1;
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.
See Anansi::Class for details. A parent module of Anansi::Singleton.
See Anansi::Class::DESTROY for details. Overridden by Anansi::Singleton::DESTROY.
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. Overridden by Anansi::Singleton::new.
See Anansi::Class::old for details.
See Anansi::Class::used for details.
See Anansi::Class::uses for details.
See Anansi::Class::using for details.
An object of this namespace.
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.
$OBJECT->fixate(); $OBJECT->SUPER::fixate();
Named parameters.
A virtual method. Called just prior to module instance object destruction where there are multiple instances of the object remaining.
my $object = Anansi::Example->new(); my $object = Anansi::Example->new( SETTING => 'example', );
Either an object or a string of this namespace.
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.
$OBJECT->reinitialise(); $OBJECT->SUPER::reinitialise();
A virtual method. Called just after module instance object recreation.
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::Singleton, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Anansi::Singleton
CPAN shell
perl -MCPAN -e shell install Anansi::Singleton
For more information on module installation, please visit the detailed CPAN module installation guide.