MouseX::SingletonMethod - Mouse with Singleton Method facility
package Foo; use MouseX::SingletonMethod; no MouseX::Singleton; package main; my $foo1 = Foo->new; my $foo2 = Foo->new; $foo1->add_singleton_method( foo => sub { 'foo' } ); say $foo1->foo; # => 'foo' say $foo2->foo; # ERROR: Can't locate object method "foo" ...
or
package Bar; use Mouse; with 'MouseX::SingletonMethod::Role'; no Mouse;
This module can create singleton methods with Mouse.
Make the object a singleton
Adds a singleton method to this object:
$foo->add_singleton_method( foo => sub { 'foo' } );
Same as above except allows multiple method declaration:
$bar->add_singleton_methods( bar1 => sub { 'bar1' }, bar2 => sub { 'bar2' }, );
Mouse MooseX::SingletonMethod
Hideaki Ohno <hide.o.j55 {at} gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MouseX::SingletonMethod, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MouseX::SingletonMethod
CPAN shell
perl -MCPAN -e shell install MouseX::SingletonMethod
For more information on module installation, please visit the detailed CPAN module installation guide.