Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Adding a method to an existing object

by draegtun (Scribe)
on Feb 17, 2012 at 16:56 UTC ( #954566=note: print w/ replies, xml ) Need Help??


in reply to Adding a method to an existing object

The following two modules on CPAN allow you to add methods to an object:

* MooseX::SingletonMethod (for Moose objects)
* Object::Method (for normal Perl objects)

Alternatively in Moose you can apply roles directly to an object:

    YourRole->meta->apply( $your_object ); # $your_object now has the methods from YourRole

I did a few blog posts on how roles work and howto implement singleton-methods (in Moose). They're listed in the MooseX::SingletonMethod CPAN page. Also this link should bring them up.

/I3az/


Comment on Re: Adding a method to an existing object
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://954566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2015-07-28 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls