Skip to content

Instantly share code, notes, and snippets.

@rfelix
Last active August 29, 2015 14:15
Show Gist options
  • Save rfelix/86313854a403db3cac0e to your computer and use it in GitHub Desktop.
Save rfelix/86313854a403db3cac0e to your computer and use it in GitHub Desktop.
Works in Ruby 1.9.3 and 2.0.0, but not Ruby 2.1 or 2.2
require 'delegate'
class Foo < SimpleDelegator
def bar
raise "Bar"
end
def method_missing(name, *args)
puts name
end
end
class Baz
end
Foo.new(Baz.new).bar
$ chruby system
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
$ ruby method_missing_test.rb
method_missing_test.rb:5:in `bar': Bar (RuntimeError)
from method_missing_test.rb:16:in `<main>'
$ chruby 2.1
$ ruby method_missing_test.rb
method_missing_test.rb:9: stack level too deep (SystemStackError)
$ chruby 2.2
$ ruby method_missing_test.rb
method_missing_test.rb:9:in `method_missing': stack level too deep (SystemStackError)
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
... 8723 levels...
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:9:in `method_missing'
from method_missing_test.rb:5:in `bar'
from method_missing_test.rb:16:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment