my methods
A useful ruby snippet that Cameron. and I came up with last night:
class Object
def self.my_methods
methods - (superclass ? superclass.methods : [])
end
def my_methods
methods - (self.class.superclass ? self.class.superclass.new.methods : [])
end
end
This is useful for finding out what methods an object has, without including all the methods inherited from super classes.
April 4th, 2012 at 10:23 pm
Thank you!! Just what I needed!!