Get direct instance methods defined in a class

I want to get all the methods that are defined directly for the class

Here is what I am doing now:

class Mine def immediate end (instance_methods - ancestors.second.instance_methods) # [:immediate] end 

Is there a better way?

+4
source share
1 answer
 Mine.instance_methods false 

It's good? or how do you like it? something like Mine.my_instance_methods? :)

+6
source

Source: https://habr.com/ru/post/1415056/


All Articles