Module: Martin::Delegator

Defined in:
lib/martin/delegator.rb

Overview

Martin delegation mixin. Mixing this module into an object causes all methods to be delegated to the Martin::Application class. Used primarily at the top-level.

92% ripped from Sinatra::Delegator

Class Method Summary collapse

Class Method Details

.delegate(mod, *methods) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
# File 'lib/martin/delegator.rb', line 8

def self.delegate(mod, *methods)
    methods.each do |method_name|
        eval <<-RUBY, binding, '(__DELEGATE__)', 1
            def #{method_name}(*args, &b)
                mod.send(#{method_name.inspect}, *args, &b)
            end
            private #{method_name.inspect}
        RUBY
    end
end