GX::Class::Singleton - Universal base class for singletons
package My::ENV; use GX::Class::Singleton; has '_env' => ( isa => 'Hash', initializer => sub { \%ENV }, accessors => { 'get' => { type => 'get_value' }, 'set' => { type => 'set_value' } } ); build; my $env = My::ENV->new; say "Hello " . $env->get( 'USER' ) . "!";
This module provides the GX::Class::Singleton class which extends the GX::Class::Object class.
new
Creates the singleton instance and returns it.
$object = $class->new( %attributes );
%attributes ( named list )
%attributes
$object ( GX::Class::Singleton object )
$object
GX::Exception
Subsequent calls to new() without arguments return the singleton instance.
new()
All public methods can be called both as instance and class methods.
clear
Resets the singleton instance's attributes to their uninitialized state. See GX::Class::Object.
$singleton->clear;
destroy
Destroys the singleton instance.
$singleton->destroy;
dump
Stringifies the singleton instance. See GX::Class::Object.
$string = $singleton->dump;
instance
Returns the singleton instance.
$object = $singleton->instance;
Implicitly calls new(), if necessary.
meta
See GX::Class::Object.
$meta = $singleton->meta;
GX::Class
GX::Meta
Jörg A. Uzarek <uzarek@runlevelnull.de>
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.