Module: Sinatra::Delegator

Included in:
Rack::Builder
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 Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.targetObject

Returns the value of attribute target.



1994
1995
1996
# File 'lib/sinatra/base.rb', line 1994

def target
  @target
end

Class Method Details

.delegate(*methods) ⇒ Object

:nodoc:



1978
1979
1980
1981
1982
1983
1984
1985
1986
# File 'lib/sinatra/base.rb', line 1978

def self.delegate(*methods)
  methods.each do |method_name|
    define_method(method_name) do |*args, &block|
      return super(*args, &block) if respond_to? method_name
      Delegator.target.send(method_name, *args, &block)
    end
    private method_name
  end
end