GX::Class::Singleton

Module Version: 0.2000_01

NAME

GX::Class::Singleton - Universal base class for singletons

SYNOPSIS

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' ) . "!";

DESCRIPTION

This module provides the GX::Class::Singleton class which extends the GX::Class::Object class.

METHODS

Constructor

new

Creates the singleton instance and returns it.

$object = $class->new( %attributes );
Arguments:
  • %attributes ( named list )
Returns:
Exceptions:

Subsequent calls to new() without arguments return the singleton instance.

Public Methods

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;
Returns:
Exceptions:

Implicitly calls new(), if necessary.

meta

See GX::Class::Object.

$meta = $singleton->meta;

Internal Methods

See GX::Class::Object.

EXPORTS

See GX::Class::Object.

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 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.