How does one - without inheritance - override a class method and call the original from within the new method?
问题 I found one source which successfully overrode Time.strftime like this: class Time alias :old_strftime :strftime def strftime #do something old_strftime end end The trouble is, strftime is an instance method. I need to override Time.now - a class method - in such away that any caller gets my new method, while the new method still calls the original .now method. I've looked at alias_method and have met with no success. 回答1: This is kinda hard to get your head around sometimes, but you need to