Created
November 27, 2012 10:29
Revisions
-
kschiess created this gist
Nov 27, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ class Foo def respond_to?(sym) if sym == :foo return true else super end end end class Bar def respond_to_missing?(sym, p) if sym == :foo return true else super end end end [Foo, Bar].each do |klass| [[:respond_to?, :foo], [:respond_to_missing?, :foo, false], [:method, :foo]].each do |method, *args| r = begin klass.new.send(method, *args) rescue => ex ex end puts "Calling #{klass}##{method.inspect}(#{args.join(', ')}) # => #{r.inspect}" end end