Module: Fleck::Core::Consumer::HelpersDefiners::ClassMethods
- Defined in:
- lib/fleck/core/consumer/helpers_definers.rb
Overview
Defines class methods to import when ‘HelpersDefilers` module is imported.
Instance Method Summary collapse
- #error_method(name, code, message) ⇒ Object
- #information_method(name, code) ⇒ Object
- #redirect_method(name, code) ⇒ Object
- #success_method(name, code) ⇒ Object
Instance Method Details
#error_method(name, code, message) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/fleck/core/consumer/helpers_definers.rb', line 14 def error_method(name, code, ) define_method(name) do |error: nil, body: nil, interrupt: true| response.render_error(code, [] + [error].flatten) response.body = body throw INTERRUPT_NAME if interrupt end end |
#information_method(name, code) ⇒ Object
35 36 37 |
# File 'lib/fleck/core/consumer/helpers_definers.rb', line 35 def information_method(name, code) success_method(name, code) end |
#redirect_method(name, code) ⇒ Object
22 23 24 |
# File 'lib/fleck/core/consumer/helpers_definers.rb', line 22 def redirect_method(name, code) success_method(name, code) end |
#success_method(name, code) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/fleck/core/consumer/helpers_definers.rb', line 26 def success_method(name, code) define_method(name) do |*args| interrupt = (args[1] ? args[1][:interrupt] : true) response.status = code response.body = args[0] throw INTERRUPT_NAME if interrupt end end |