Created
September 7, 2012 19:00
-
-
Save chrisb/3668627 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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