Module: Sinatra::Delegator

Defined in:
lib/sinatra/base.rb

Overview

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

Class Method Summary collapse

Class Method Details

.delegate(*methods) ⇒ Object

:nodoc:



1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
# File 'lib/sinatra/base.rb', line 1109

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