Why not adopt me?
This distribution is up for adoption!
If you're interested then please contact the PAUSE module admins via
email.
NAME
Bot::Cobalt::Core::Role::Singleton
SYNOPSIS
package MySingleton;
use Moo;
with 'Bot::Cobalt::Core::Role::Singleton';
DESCRIPTION
A basic Moo::Role implementing singletons for Bot::Cobalt.
A singleton is a class that can only be instanced once.
Classes can consume this Role in order to gain the following methods:
instance
The instance method returns the existing singleton if there is one, or calls new to create one if not. Consumers should be instanced by calling instance rather than new:
## Bot::Cobalt::Core is a singleton:
my $core = Bot::Cobalt::Core->instance(
cfg => Bot::Cobalt::Conf->new(etc => $etc),
var => $var,
);
Arguments are passed to new() unmodified (if we are creating a new singleton).
has_instance
Returns boolean false if there is currently no instance.
clear_instance
Clear the singleton instance.
AUTHOR
Jon Portnoy <avenj@cobaltirc.org>
(Essentially the same as other singleton implementations such as Class::Singleton, MooseX::Singleton, MooX::Singleton etc)