开发者

One-liner to Count the Number of Methods I've defined in a Ruby Class?

开发者 https://www.devze.com 2023-02-17 05:39 出处:网络
What\'s the simplest way I can list the methods defined at each level in the tree? Admin < User < ActiveRecord::Base开发者_如何学JAVA < ...

What's the simplest way I can list the methods defined at each level in the tree?

Admin < User < ActiveRecord::Base开发者_如何学JAVA < ...

...and be able to take those methods and say which we defined in which module.


Admin.ancestors.each{|a| puts "For #{a} #{a.instance_methods(false)}"}
0

精彩评论

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