I have defined a module Vehicle like such
module Vehicle
class <<self
def build
end
private
def background
end
end
end
A call to Vehicle.singleton_methods returns [:build].
How can I inspect all private singleton methods defined by Vehicle?
In Ruby 1.9+, you can simply do:
In Ruby 1.8, things are a bit more complicated.
will return all private methods. You can filter most of the ones declared outside by doing
but that doesn’t get quite all of them out, you have to create a module to do that
This last one has the unfortunate requirement of creating a module only to throw it away.