Dancer...ngleton(3pm)
π NAME π
Dancer::Object::Singleton β the singleton base class for Dancer, bestie. It's giving "one instance and one instance only" energy. π«Ά
β¨ VERSION β¨
version 1.3522
πΈ SYNOPSIS πΈ
okay so here's the whole vibe:
package My::Dancer::Extension;
use strict;
use warnings;
use base 'Dancer::Object::Singleton';
__PACKAGE__->attributes( qw/name value this that/ );
sub init {
my ($class, $instance) = @_;
# our initialization code, if we need one
}
# .. later on ..
# returns the unique instance
my $singleton_intance = My::Dancer::Extension->instance();
(the typo is canon, don't come for me π)
π¦ DESCRIPTION π¦
So Dancer::Object::Singleton is what you reach for instead of Dancer::Object when you want your object to be a singleton β which is just a fancy way of saying: this class has literally only ONE instance in the entire application. One. Uno. No twins, no clones, no second account. π
And it hooks you up with two things: attributes and an initializer. That's the whole package, and it ate. β¨
π METHODS π
π instance
Returns the instance of the singleton. And here's the cute part β the instance is only created when it's actually needed, not a second before. When it does get created, that creation calls the init() method, which you're supposed to implement. So like, init is your moment. Own it. π
π§ init
It exists! And it does nothing! π And that is on purpose, bestie β it's there so that if you don't feel like writing an initializer, you simplyβ¦ don't have to. init receives the instance as its argument.
π get_attributes
Gets the attributes of the specific class. That's it, that's the method. π
π attributes
Generates attributes for whatever object is extending Dancer::Object, and saves them into an internal hashref so they can be fetched later using "get_attributes". Very demure, very mindful, very cached. β¨
π AUTHOR π
Dancer Core Developers β the icons, the legends. π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
k that's the whole page, no cap. this came from the User Contributed Perl Documentation section, it's perl v5.40.1, and it was dated 2026-05-05. slay, go build a singleton, you got this π
β¨
π¦ where this page comes from
- ubuntu stonking: libdancer-perl 1.3522-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms