MooseX::SingletonMethod::Role - Role providing Singleton Method option


MooseX-SingletonMethod documentation  | view source Contained in the MooseX-SingletonMethod distribution.

Index


NAME

Top

MooseX::SingletonMethod::Role - Role providing Singleton Method option

VERSION

Top

Version 0.02

SYNOPSIS

Top

Simple usage example....

    package Baz;
    use Moose;
    with 'MooseX::SingletonMethod::Role';
    no Moose;

    package main;
    my $baz = Baz->new;
    my $foo = Baz->new;

    # add singleton method called "baz" just to $baz and not to Baz class
    $baz->add_singleton_method( baz => sub { 'baz!' } ); 

    say $baz->baz;   # => 'baz'
    say $foo->baz;   # ERROR: Can't locate object method "baz"....




DESCRIPTION

Top

See MooseX::SingletonMethod for full documentation.

EXPORT

Top

None

METHODS

Top

become_singleton

Makes the object a singleton (by creating an anonymous class which the object is blessed with):

    $baz->become_singleton;




add_singleton_method

Adds a singleton method to this object (same as above + creates prescribed method):

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

add_singleton_methods

Same as above except allows multiple method declaration:

    $baz->add_singleton_methods(  
        baz1 => sub { 'baz1!' },  
        baz2 => sub { 'baz2!' },  
    );







AUTHOR

Top

Barry Walsh, <draegtun at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-moosex-singletonmethod at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-SingletonMethod. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc MooseX::SingletonMethod::Role




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-SingletonMethod

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MooseX-SingletonMethod

* CPAN Ratings

http://cpanratings.perl.org/d/MooseX-SingletonMethod

* Search CPAN

http://search.cpan.org/dist/MooseX-SingletonMethod/

ACKNOWLEDGEMENTS

Top

DISCLAIMER

Top

This is beta software. I'll strive to make it better each and every day!

However I accept no liability whatsoever should this software do what you expected ;-)

COPYRIGHT & LICENSE

Top


MooseX-SingletonMethod documentation  | view source Contained in the MooseX-SingletonMethod distribution.