Class: Otto::ResponseHandlers::ViewHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Otto::ResponseHandlers::ViewHandler
- Defined in:
- lib/otto/response_handlers.rb
Overview
Handler for view/template responses
Class Method Summary collapse
Class Method Details
.handle(result, response, context = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/otto/response_handlers.rb', line 59 def self.handle(result, response, context = {}) if context[:logic_instance]&.respond_to?(:view) response.body = [context[:logic_instance].view.render] response['Content-Type'] = 'text/html' unless response['Content-Type'] elsif result.respond_to?(:to_s) response.body = [result.to_s] response['Content-Type'] = 'text/html' unless response['Content-Type'] else response.body = [''] end ensure_status_set(response, context[:status_code] || 200) end |