Our Daily Method #13: Object#mymethods
Geplaatst door Michiel de Mare do, 21 feb 2008 08:00:00 GMT
I always have an irb or rails console session open, and I love methods
to see what an object is capable of, but it certainly returns an exceptional amount of unsorted crap, especially in Rails.
Therefore, mymethods
:
class Object
def mymethods
(methods - Object.instance_methods).sort
end
end
(1..2).methods.size # => 150
(1..2).mymethods.size # => 46
Admittedly it’s not all that revolutionary, but I mentioned the identical technique (with a different method name) at about the same time, here: http://wisdom.inventivelabs.com.au/post/26671565
Something in the zeitgeist, I guess. ;)