Skip to content

Instantly share code, notes, and snippets.

@tnoborio
Created March 21, 2010 13:58
Show Gist options
  • Save tnoborio/339314 to your computer and use it in GitHub Desktop.
Save tnoborio/339314 to your computer and use it in GitHub Desktop.
class A
def m1
p 'm1'
end
def m2
p 'm2'
end
end
class Object
def chain
o = Object.new
o.instance_variable_set(:@t, self)
def o.method_missing(name, *args)
@t.__send__ name, *args
self
end
o
end
end
A.new.chain.m1.m2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment