1MooX::Singleton(3) User Contributed Perl Documentation MooX::Singleton(3)
2
3
4
6 MooX::Singleton - turn your Moo class into singleton
7
9 version 1.20
10
12 package MyApp;
13 use Moo;
14 with 'MooX::Singleton';
15
16 package main;
17
18 my $instance = MyApp->instance(@optional_init_args);
19 my $same = MyApp->instance;
20
22 Role::Tiny role that provides "instance" method turning your object
23 into singleton.
24
26 instance
27 my $singleton = MyApp->instance(@args1);
28 my $same = MyApp->instance;
29 # @args2 are ignored
30 my $above = MyApp->instance(@args2);
31
32 Creates a new object initialized with arguments provided and then
33 returns it.
34
35 NOTE: Subsequent calls to "instance" will return the singleton instance
36 ignoring any arguments. This is different from MooseX::Singleton which
37 does not allow any arguments.
38
40 Alex J. G. Burzyński <ajgb@cpan.org>
41
43 This software is copyright (c) 2012 by Alex J. G. Burzyński
44 <ajgb@cpan.org>.
45
46 This is free software; you can redistribute it and/or modify it under
47 the same terms as the Perl 5 programming language system itself.
48
49
50
51perl v5.36.0 2023-01-20 MooX::Singleton(3)