Skip to content

Instantly share code, notes, and snippets.

@alebian
Created October 19, 2017 12:49
Show Gist options
  • Save alebian/002895b01cb458f8fac63d56358eb4d3 to your computer and use it in GitHub Desktop.
Save alebian/002895b01cb458f8fac63d56358eb4d3 to your computer and use it in GitHub Desktop.
module Test
class Base
def hello
puts 'Hello'
end
end
Application = Base.new
module Delegator
def self.delegate(*methods, to:)
Array(methods).each do |method_name|
define_method(method_name) do |*args, &block|
to.send(method_name, *args, &block)
end
private method_name
end
end
delegate :hello, to: Application
end
end
include Test::Delegator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment