Skip to content

Instantly share code, notes, and snippets.

@chrisb
Created Sep 7, 2012
Embed
What would you like to do?
class Foo
def hello
do_something_really_destructive!
end
protected
def bar
do_something_really_destructive!
end
end
class Object
def really_respond_to?(method)
begin
self.send(method)
return true
rescue NoMethodError
return false
end
end
end
x = Foo.new
x.respond_to?(:hello) # => true
x.respond_to?(:bar) # => false
x.really_respond_to?(:bar) # => true, but something really destructive happened!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment