Module: Roda::RodaPlugins::ModuleInclude::ClassMethods
- Defined in:
- lib/roda/plugins/module_include.rb
Instance Method Summary collapse
-
#request_module(mod = nil, &block) ⇒ Object
Include the given module in the request class.
-
#response_module(mod = nil, &block) ⇒ Object
Include the given module in the response class.
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
36 37 38 |
# File 'lib/roda/plugins/module_include.rb', line 36 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
55 56 57 |
# File 'lib/roda/plugins/module_include.rb', line 55 def response_module(mod = nil, &block) module_include(:response, mod, &block) end |