MooX::Singleton(3pm)

πŸ“¦
version 1.20 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– MooX::Singleton πŸ’–

okay bestie, so this is MooX::Singleton β€” the Perl module that takes your cute little Moo class and makes it a singleton. one instance. one. that's the whole vibe. πŸ‘‘

version 1.20 β€” yes she's been around, she's iconic, she's stable.


✨ SYNOPSIS ✨

package MyApp;
use Moo;
with 'MooX::Singleton';

package main;

my $instance = MyApp->instance(@optional_init_args);
my $same = MyApp->instance;

like. look at her. with 'MooX::Singleton' and boom, you got yourself an instance. 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a Role::Tiny role, and what it does is hand you an instance method that turns your object into a singleton. that's it. that's the whole job. she's lowkey minimal and highkey perfect for it. πŸ’…


πŸŽ€ METHODS πŸŽ€

instance

my $singleton = MyApp->instance(@args1);
my $same = MyApp->instance;
# @args2 are ignored
my $above = MyApp->instance(@args2);

what she does: creates a new object initialized with the arguments you gave her, and then returns it. ✨

NOTE: subsequent calls to instance will return the singleton instance and ignore any arguments you pass. literally just ignore them. no cap. πŸ™ˆ this is different from MooseX::Singleton, which doesn't allow any arguments at all. so like, different energy entirely. iykyk.

πŸ‘‘ AUTHOR πŸ‘‘

Alex J. G. BurzyXski <ajgb@cpan.org>


This software is copyright (c) 2012 by Alex J. G. BurzyXski <ajgb@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🫢


and that's the whole page, bestie!! 🌈 this one's from perl v5.34.0, dated 2022-06-16, and it lives at MooX::Singleton(3pm). go make some singletons, you absolute main character. πŸ§šπŸ’–βœ¨

πŸ“¦ where this page comes from