/usr/share/perl5/MooX/Singleton.pm is in libmoox-singleton-perl 1.20-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | package MooX::Singleton;
BEGIN {
$MooX::Singleton::AUTHORITY = 'cpan:AJGB';
}
{
$MooX::Singleton::VERSION = '1.20';
}
# ABSTRACT: turn your Moo class into singleton
use strict;
use warnings;
use Role::Tiny;
sub instance {
my $class = shift;
no strict 'refs';
my $instance = \${"$class\::_instance"};
return defined $$instance ? $$instance
: ( $$instance = $class->new(@_) );
}
sub _has_instance {
my $class = ref $_[0] || $_[0];
no strict 'refs';
return ${"$class\::_instance"};
}
sub _clear_instance {
my $class = ref $_[0] || $_[0];
no strict 'refs';
undef ${"$class\::_instance"};
return $class;
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
MooX::Singleton - turn your Moo class into singleton
=head1 VERSION
version 1.20
=head1 SYNOPSIS
package MyApp;
use Moo;
with 'MooX::Singleton';
package main;
my $instance = MyApp->instance(@optional_init_args);
my $same = MyApp->instance;
=head1 DESCRIPTION
Role::Tiny role that provides L<"instance"> method turning your object into singleton.
=head1 METHODS
=head2 instance
my $singleton = MyApp->instance(@args1);
my $same = MyApp->instance;
# @args2 are ignored
my $above = MyApp->instance(@args2);
Creates a new object initialized with arguments provided and then returns it.
NOTE: Subsequent calls to C<instance> will return the singleton instance ignoring
any arguments. This is different from L<MooseX::Singleton> which does not allow any
arguments.
=head1 AUTHOR
Alex J. G. Burzyński <ajgb@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Alex J. G. Burzyński <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.
=cut
|