module Roda::RodaPlugins::ModuleInclude::ClassMethods
def module_include(type, mod, &block)
def module_include(type, mod, &block) if type == :response klass = self::RodaResponse iv = :@response_module else klass = self::RodaRequest iv = :@request_module end if mod raise RodaError, "can't provide both argument and block to response_module" if defined?(yield) klass.send(:include, mod) else if instance_variable_defined?(iv) mod = instance_variable_get(iv) else mod = instance_variable_set(iv, Module.new) klass.send(:include, mod) end mod.module_eval(&block) if block end mod end
def request_module(mod = nil, &block)
r.description
Roda.route do |r|
end
end
"#{request_method} #{path_info}"
def description
Roda.request_module do
Roda.request_module SomeModule
the block. Example:
is provided instead of a module, create a module using the
Include the given module in the request class. If a block
def request_module(mod = nil, &block) module_include(:request, mod, &block) end
def response_module(mod = nil, &block)
response.error!
Roda.route do |r|
end
end
self.status = 500
def error!
Roda.response_module do
Roda.response_module SomeModule
the block. Example:
is provided instead of a module, create a module using the
Include the given module in the response class. If a block
def response_module(mod = nil, &block) module_include(:response, mod, &block) end