Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: v1.1.5
Fetching contributors…

Cannot retrieve contributors at this time

16 lines (15 sloc) 0.432 kb
class Module
def delegate(*methods)
options = methods.pop
unless options.is_a?(Hash) && to = options[:to]
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key"
end
methods.each do |method|
module_eval(<<-EOS, "(__DELEGATION__)", 1)
def #{method}(*args, &block)
#{to}.__send__(#{method.inspect}, *args, &block)
end
EOS
end
end
end
Jump to Line
Something went wrong with that request. Please try again.