Skip to content

Instantly share code, notes, and snippets.

@chrisb
Created September 7, 2012 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisb/3668627 to your computer and use it in GitHub Desktop.
Save chrisb/3668627 to your computer and use it in GitHub Desktop.
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