Module: Sinatra::Delegator

Included in:
Rack::Builder
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.5/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.



1986
1987
1988
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.5/lib/sinatra/base.rb', line 1986

def target
  @target
end

Class Method Details

.delegate(*methods) ⇒ Object

:nodoc:



1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.5/lib/sinatra/base.rb', line 1967

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
    # ensure keyword argument passing is compatible with ruby >= 2.7
    ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
    private method_name
  end
end