Module: ActiveFunction::Functions::Rendering
- Defined in:
- lib/active_function/functions/rendering.rb
Overview
Allows manipulations with SuperBase#response via #render instance method.
Defined Under Namespace
Classes: DoubleRenderError
Constant Summary collapse
- Error =
Class.new(StandardError)
- DEFAULT_HEADER =
{"Content-Type" => "application/json"}.freeze
Instance Method Summary collapse
-
#render(status: 200, json: {}, head: {}) ⇒ Object
Render JSON response.
Instance Method Details
#render(status: 200, json: {}, head: {}) ⇒ Object
Render JSON response.
47 48 49 50 51 52 53 54 55 |
# File 'lib/active_function/functions/rendering.rb', line 47 def render(status: 200, json: {}, head: {}) raise DoubleRenderError, @action_name if performed? @response.status = status @response.headers = head.merge(Hash[DEFAULT_HEADER]) @response.body = JSON.generate(json) @response.commit! end |