Skip to content

MooseX::SingletonMethod now on CPAN

July 15, 2009

So has promised or was it threatened I’ve packaged and uploaded MooseX::SingletonMethod to CPAN.

Here is the synopsis from the pod:

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"....

MooseX is the namespace for adding extensions around Moose. Its the playground of future Moose features where modules get torn, beaten and bruised in a development rite of passage.

It would one day be nice to see MooseX::SingletonMethod features grow up and become part of standard Moose family πŸ™‚

MooseX::SingletonMethod can also be found in these exotic areas of the web:

/I3az/

 

PS. While sticking my flag into the MooseX::SingletonMethod namespace I noticed the following module by Simon Cozens:

I’m amazed this as passed me by especially has I first came to understand Singleton Methods from Simon’s excellent “Advanced Perl Programming” book. Just shows you how deep and diverse the CPAN universe is!

Update: Code now uses MX::SM::Role

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: