Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created October 7, 2011 03:46
Show Gist options
  • Save mhorbul/1269397 to your computer and use it in GitHub Desktop.
Save mhorbul/1269397 to your computer and use it in GitHub Desktop.
require 'forwardable'
class A
def foo(*args)
puts "from A; #{args.inspect}"
end
end
class C
extend Forwardable
def_delegator :a, :foo
def a
@a ||= A.new
end
end
c = C.new
c.foo # => from A; []
c.foo(1,2,3) # => from A; [1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment