1Dancer::Object::SingletUosne(r3)Contributed Perl DocumenDtaantcieorn::Object::Singleton(3)
2
3
4

NAME

6       Dancer::Object::Singleton - Singleton base class for Dancer
7

VERSION

9       version 1.3513
10

SYNOPSIS

12           package My::Dancer::Extension;
13
14           use strict;
15           use warnings;
16           use base 'Dancer::Object::Singleton';
17
18           __PACKAGE__->attributes( qw/name value this that/ );
19
20           sub init {
21               my ($class, $instance) = @_;
22               # our initialization code, if we need one
23           }
24
25           # .. later on ..
26
27           # returns the unique instance
28           my $singleton_intance = My::Dancer::Extension->instance();
29

DESCRIPTION

31       Dancer::Object::Singleton is meant to be used instead of
32       Dancer::Object, if you want your object to be a singleton, that is, a
33       class that has only one instance in the application.
34
35       It provides you with attributes and an initializer.
36

METHODS

38   instance
39       Returns the instance of the singleton. The instance is created only
40       when needed. The creation will call the "init()" method, which you
41       should implement.
42
43   init
44       Exists but does nothing. This is so you won't have to write an
45       initializer if you don't want to. init receives the instance as
46       argument.
47
48   get_attributes
49       Get the attributes of the specific class.
50
51   attributes
52       Generates attributes for whatever object is extending Dancer::Object
53       and saves them in an internal hashref so they can be later fetched
54       using "get_attributes".
55

AUTHOR

57       Dancer Core Developers
58
60       This software is copyright (c) 2010 by Alexis Sukrieh.
61
62       This is free software; you can redistribute it and/or modify it under
63       the same terms as the Perl 5 programming language system itself.
64
65
66
67perl v5.32.0                      2020-07-28      Dancer::Object::Singleton(3)
Impressum