Module: Roda::RodaPlugins::ModuleInclude::ClassMethods

Defined in:
lib/roda/plugins/module_include.rb

Instance Method Summary collapse

Instance Method Details

#request_module(mod = nil, &block) ⇒ Object

Include the given module in the request class. If a block is provided instead of a module, create a module using the the block. Example:

Roda.request_module SomeModule

Roda.request_module do
  def description
    "#{request_method} #{path_info}"
  end
end

Roda.route do |r|
  r.description
end


39
40
41
# File 'lib/roda/plugins/module_include.rb', line 39

def request_module(mod = nil, &block)
  module_include(:request, mod, &block)
end

#response_module(mod = nil, &block) ⇒ Object

Include the given module in the response class. If a block is provided instead of a module, create a module using the the block. Example:

Roda.response_module SomeModule

Roda.response_module do
  def error!
    self.status = 500
  end
end

Roda.route do |r|
  response.error!
end


58
59
60
# File 'lib/roda/plugins/module_include.rb', line 58

def response_module(mod = nil, &block)
  module_include(:response, mod, &block)
end