如何在baz方法调用中获取所有实例方法名称,这些名称仅出现在Bar模块中(没有此类的其他实例方法)?
class Foo
include Bar
def a
end
def b
end
def baz
#HERE
end
end
答案 0 :(得分:5)
class Foo
include Bar
def a
end
def b()
end
def baz
Bar.instance_methods(false)
end
end
puts Foo.new.baz