Bot::Cobalt::Core::Role::Singleton
package MySingleton; use Moo; with 'Bot::Cobalt::Core::Role::Singleton';
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:
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).
Returns boolean false if there is currently no instance.
Clear the singleton instance.
Jon Portnoy <avenj@cobaltirc.org>
(Essentially the same as other singleton implementations such as Class::Singleton, MooseX::Singleton, MooX::Singleton etc)
To install Bot::Cobalt, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bot::Cobalt
CPAN shell
perl -MCPAN -e shell install Bot::Cobalt
For more information on module installation, please visit the detailed CPAN module installation guide.