Mouse with Singleton Metod facility
Perl
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/MouseX
t
xt
.gitignore
.travis.yml
Build.PL
Changes
LICENSE
META.json
README.md
cpanfile

README.md

NAME

MouseX::SingletonMethod - Mouse with Singleton Method facility

SYNOPSIS

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;

DESCRIPTION

This module can create singleton methods with Mouse.

METHODS

become_singleton

Make the object a singleton

add_singleton_method

Adds a singleton method to this object:

$foo->add_singleton_method( foo => sub { 'foo' } );

add_singleton_methods

Same as above except allows multiple method declaration:

$bar->add_singleton_methods(
    bar1 => sub { 'bar1' },
    bar2 => sub { 'bar2' },
);

SEE ALSO

Mouse MooseX::SingletonMethod

AUTHOR

Hideaki Ohno <hide.o.j55 {at} gmail.com>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.