Dmytrii Nagirniak
Dmytrii Nagirniak

Reputation: 24118

Obtain direct instance methods defined on a class

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

Here is what I currently do:

class Mine
  def immediate
  end

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

Is there a better way?

Upvotes: 4

Views: 202

Answers (1)

Amol Pujari
Amol Pujari

Reputation: 2349

Mine.instance_methods false

does this look good? or how do you like to write it? something like Mine.my_instance_methods? :)

Upvotes: 6

Related Questions