alias_method for static method

B

Borja Martín

Hi,
I was wondering if it is possible to create aliases for class methods,
as alias_method seems to work only for instance methods.
Thanks in advance
 
D

dblack

---2049402039-1354733574-1181943948=:1863
Content-Type: MULTIPART/MIXED; BOUNDARY="-2049402039-1354733574-1181943948=:1863"

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

---2049402039-1354733574-1181943948=:1863
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

Hi --

Hi,
I was wondering if it is possible to create aliases for class methods, as= =20
alias_method seems to work only for instance methods.
Thanks in advance

Class methods are singleton methods defined in a class's singleton
class. So, to get into the right scope you would do:

class << YourClass

and then you can use alias and/or alias_method.


David

--=20
* Books:
RAILS ROUTING (new! http://safari.awprofessional.com/9780321509246)
RUBY FOR RAILS (http://www.manning.com/black)
* Ruby/Rails training
& consulting: Ruby Power and Light, LLC (http://www.rubypal.com)
---2049402039-1354733574-1181943948=:1863--
---2049402039-1354733574-1181943948=:1863--
 
B

Borja Martín

Thanks a lot, it worked like a charm.

(e-mail address removed) escribió:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top