Hi!
I’ve run into problem aliasing a class method, i.e. I have: class Abc self.get_abc arg … end end And later I need to this method, with saving of original implementation. Following code is not working: alias :orig_get_abc, :get_abc
– sdmitry -=- Dmitry V. Sabanin MuraveyLabs.
Following code is not working: alias :orig_get_abc, :get_abc
you need to be in the singleton class to make the alias
svg% cat b.rb #!/usr/bin/ruby class Abc def self.get_abc arg puts "abc" end class << self alias orig_get_abc get_abc end end
Abc.orig_get_abc(12) svg%
svg% b.rb abc svg%
Guy Decoux
Very nice, thank you!
On Tuesday 16 September 2003 23:43, ts wrote:
you need to be in the singleton class to make the alias svg% cat b.rb #!/usr/bin/ruby class Abc def self.get_abc arg puts “abc” end class << self alias orig_get_abc get_abc end end Abc.orig_get_abc(12) svg% svg% b.rb abc svg% Guy Decoux
svg% cat b.rb #!/usr/bin/ruby class Abc def self.get_abc arg puts “abc” end class << self alias orig_get_abc get_abc end end