Skip to content

Instantly share code, notes, and snippets.

@gnab
Created January 14, 2010 19:05
Show Gist options
  • Save gnab/277396 to your computer and use it in GitHub Desktop.
Save gnab/277396 to your computer and use it in GitHub Desktop.
# http://railstips.org/blog/archives/2009/08/07/patterns-are-not-scary-method-missing-proxy/
class BasicObject #:nodoc:
instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval/ }
end unless defined?(BasicObject)
class Proxy < BasicObject
def initialize(subject)
@subject = subject
end
private
def method_missing(method, *args, &block)
@subject.send(method, *args, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment