Module: Sinatra::Delegator
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/sinatra/base.rb |
Overview
::Sinatra
delegation mixin. Mixing this module into an object causes all
methods to be delegated to the Application
class. Used primarily
at the top-level.
Class Attribute Summary
- .target rw
Class Method Summary
-
.delegate(*methods)
:nodoc:
Class Attribute Details
.target (rw)
[ GitHub ]# File 'lib/sinatra/base.rb', line 2123
attr_accessor :target
Class Method Details
.delegate(*methods)
:nodoc:
# File 'lib/sinatra/base.rb', line 2104
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