Forum: Ruby alias_method for static method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
90ea347c45cdfbc1c5767dd6304d9c10?d=identicon&s=25 Borja Martín (Guest)
on 2007-06-15 23:38
(Received via mailing list)
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
1fba4539b6cafe2e60a2916fa184fc2f?d=identicon&s=25 unknown (Guest)
on 2007-06-15 23:46
(Received via mailing list)
Hi --

On Sat, 16 Jun 2007, Borja Martín wrote:

> 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

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
90ea347c45cdfbc1c5767dd6304d9c10?d=identicon&s=25 Borja Martín (Guest)
on 2007-06-16 00:01
(Received via mailing list)
Thanks a lot, it worked like a charm.

dblack@wobblini.net escribió:
This topic is locked and can not be replied to.