[英]ruby: how to get all the methods that are defined or overwrited in current class rather than base class?
Does anyone how to get all the methods that are defined or overwrited in current class rather than base class? 有谁能获得在当前类而不是基类中定义或覆盖的所有方法? eg
例如
class MyBase
def Test
end
end
class MyDerived
def Test1
end
end
When I call MyDerived.methods, i got a lot of methods, but I only want to get 'Test1' because it is its own method, is it possible? 当我调用MyDerived.methods时,我有很多方法,但是我只想获取'Test1',因为它是它自己的方法,可以吗? thanks.
谢谢。
class Foo
def bar
end
end
Foo.new.public_methods false
=> [:bar]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.