开发者

Get included method names

开发者 https://www.devze.com 2023-04-08 06:39 出处:网络
How I can get all instance method names in the baz method call, which are only present in the Bar module (without other instance methods of this class) ?

How I can get all instance method names in the baz method call, which are only present in the Bar module (without other instance methods of this class) ?

class F开发者_如何学Coo
  include Bar

  def a
  end

  def b
  end

  def baz
    #HERE
  end
end


class Foo
  include Bar

  def a
  end

  def b()
  end

  def baz
    Bar.instance_methods(false)
  end
end

puts Foo.new.baz
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号