When monkey patching an instance method, can you call the overridden method from the new implementation?

前端 未结 3 1239
深忆病人
深忆病人 2020-11-22 03:01

Say I am monkey patching a method in a class, how could I call the overridden method from the overriding method? I.e. Something a bit like super

E.g.

3条回答
  •  一生所求
    2020-11-22 03:39

    Take a look at aliasing methods, this is kind of renaming the method to a new name.

    For more information and a starting point take a look at this replacing methods article (especially the first part). The Ruby API docs, also provides (a less elaborate) example.

提交回复
热议问题