Skip to content

Instantly share code, notes, and snippets.

@bbozo
Created April 1, 2015 10:32
Show Gist options
  • Save bbozo/d1d75597ddf91996b098 to your computer and use it in GitHub Desktop.
Save bbozo/d1d75597ddf91996b098 to your computer and use it in GitHub Desktop.
class Proxy
def initialize(object)
@object = object
end
def method_missing method, *args, &block
if @object.respond_to? method
@object.send(method, *args, &block).to_s
else
super method, *args, &block
end
end
def respond_to? method, private = false
super(method, private) || @object.respond_to?(method, private)
end
end
class Roko < Struct.new(:a, :b, :c)
end
roko = Proxy.new(Roko.new)
puts roko.a.class
puts roko.a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment