Module: BeyondTheApi::RenderHelpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/beyond_the_api/render_helpers.rb
Instance Method Summary collapse
- #render_json_errors(object) ⇒ Object
- #render_json_message(hash, status, optionals = {}) ⇒ Object
- #render_json_message_with_serializer(object, options = {}) ⇒ Object
Instance Method Details
#render_json_errors(object) ⇒ Object
25 26 27 28 29 |
# File 'lib/beyond_the_api/render_helpers.rb', line 25 def render_json_errors(object) errors = object.errors render json: { errors: errors., full_error_messages: errors., meta: @meta }, status: 422 end |
#render_json_message(hash, status, optionals = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/beyond_the_api/render_helpers.rb', line 19 def (hash, status, optionals = {}) hash = hash.merge(meta: @meta) hash = hash.merge(optionals) render json: hash, status: status end |
#render_json_message_with_serializer(object, options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/beyond_the_api/render_helpers.rb', line 12 def (object, = {}) hash = serialized_object_with_root(object, [:serializer_root]) hash.merge!([:message]) hash[:meta] = @meta render json: hash, status: ([:status] || :ok) end |