Module: Cyberweb::RouteHandler::Delegator

Defined in:
lib/cyberweb/route_handler/route_handler.rb

Class Method Summary collapse

Class Method Details

.delegate(*methods, to:) ⇒ Object

#

Delegator.delegate

#


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cyberweb/route_handler/route_handler.rb', line 33

def self.delegate(*methods, to:)
  work_on_these_entries = Array(methods) # Such as: [:get, :patch, :put, :post, :delete, :head]
  work_on_these_entries.each { |use_this_method_name|
    # ===================================================================== #
    # Define the toplevel method next:
    # ===================================================================== #
    define_method(use_this_method_name) { |*args, &block|
      to.send(use_this_method_name, *args, &block)
    }
    private use_this_method_name
  }
end