【发布时间】:2013-01-02 12:51:36
【问题描述】:
可能重复:
When monkey patching a method, can you call the overridden method from the new implementation?
所以我希望通过覆盖它来简单地向方法添加一些条件检查,但是我希望调用原始方法。在 ruby 中如何做到这一点?
即。
方法存在
def fakeMethod(cmd)
puts "#{cmd}"
end
我想添加
if (cmd) == "bla"
puts "caught cmd"
else
fakeMethod(cmd)
end
有什么想法吗?
【问题讨论】:
标签: ruby