Class: Module
Instance Method Summary collapse
Instance Method Details
#delegate(*methods) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/core_ext/module.rb', line 2 def delegate(*methods) = methods.pop raise ArgumentError, "Delegation needs a target." unless .is_a?(Hash) && to = [:to] methods.each do |method| module_eval(<<-EOS, "(__DELEGATION__)", 1) def #{method}(*args, &block) #{to}.__send__(#{method.inspect}, *args, &block) end EOS end end |