Created
April 1, 2015 10:32
-
-
Save bbozo/d1d75597ddf91996b098 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 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