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
-
.target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
-
.delegate(*methods) ⇒ Object
:nodoc:.
Class Attribute Details
.target ⇒ Object
Returns the value of attribute target.
2094 2095 2096 |
# File 'lib/sinatra/base.rb', line 2094 def target @target end |
Class Method Details
.delegate(*methods) ⇒ Object
:nodoc:
2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 |
# File 'lib/sinatra/base.rb', line 2075 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 |