Anansi::Actor - A dynamic usage module definition
use Anansi::Actor; my $object = Anansi::Actor->new( PACKAGE => 'Anansi::Example', ); $object->someSubroutine() if(defined($object)); use Anansi::Actor; use Data::Dumper qw(Dumper); my %modules = Anansi::Actor->modules(); if(defined($modules{DBI})) { Anansi::Actor->new( PACKAGE => 'DBI', ); print Data::Dumper::Dumper(DBI->available_drivers()); } use Anansi::Actor; use Data::Dumper qw(Dumper); if(1 == Anansi::Actor->modules( PACKAGE => 'DBI', )) { Anansi::Actor->new( PACKAGE => 'DBI', ); print Data::Dumper::Dumper(DBI->available_drivers()); }
This is a dynamic usage module definition that manages the loading of a required namespace and blessing of an object of the namespace as required. Uses Fcntl, File::Find, File::Spec::Functions and FileHandle.
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.
See Anansi::Singleton for details. A parent module of Anansi::Actor.
See Anansi::Class for Class. A parent module of Anansi::Singleton.
See Anansi::Singleton::DESTROY for details. Overrides Anansi::Class::DESTROY.
See Anansi::Singleton::fixate for details. A virtual method.
See Anansi::Singleton::new for details. Overrides Anansi::Class::new. Overridden by Anansi::Actor::new.
See Anansi::Singleton::reinitialise for details. A virtual method.
my %MODULES = $object->modules(); use Anansi::Actor; my %MODULES = Anansi::Actor->modules( INTERVAL => 3600, ); if(1 == $object->modules( PACKAGE => [ 'Some::Module::Namespace', 'Another::Module::Namespace', 'Yet::Another::Module::Namespace' ], )) { print 'The modules have been found.'."\n"; } use Anansi::Actor; my $MODULE = 'Some::Module::Namespace'; if(0 == Anansi::Actor->modules( PACKAGE => $MODULE, INTERVAL => 43200, )) { print 'The "'.$MODULE.'" module has not been found.'."\n"; }
An object of this namespace.
Named parameters.
Specifies a refresh interval in seconds. Defaults to 86400 seconds (1 day).
An ARRAY of module namespaces or a module namespace to find on the operating system.
Builds a HASH of all the modules and their paths that are available on the operating system and either returns the module HASH or a 1 (one) on success and a 0 (zero) on failure when determining the existence of the modules that are specified in the PACKAGE parameter. A temporary file "Anansi-Actor.#" will be created if at all possible to improve the speed of this subroutine by storing the module HASH. The temporary file will automatically be updated when this subroutine is subsequently run when the number of seconds specified in the INTERVAL parameter or a full day has passed. Deleting the temporary file will also cause an update to occur.
my $object = Anansi::Actor->new( PACKAGE => 'Anansi::Example', );
Either an object or a string of this namespace.
The name of the subroutine within the namespace that creates a blessed object of the namespace. Defaults to "new".
An array of the names to import from the loading module.
The namespace of the module to load.
Either An array or a hash of the parameters to pass to the blessing subroutine.
Overrides (Anansi::Singleton::new). Instantiates an object instance of a dynamically loaded module.
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::Actor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Anansi::Actor
CPAN shell
perl -MCPAN -e shell install Anansi::Actor
For more information on module installation, please visit the detailed CPAN module installation guide.