Class: Wallaby::JsonApiResponder

Inherits:
ResourcesResponder show all
Defined in:
lib/responders/wallaby/json_api_responder.rb

Overview

Easter egg: simple responder for JSON API

Instance Method Summary collapse

Methods inherited from ResourcesResponder

#to_csv

Instance Method Details

#to_htmlObject

See Also:



9
10
11
# File 'lib/responders/wallaby/json_api_responder.rb', line 9

def to_html
  to_json
end

#to_jsonString

Returns JSON.

Returns:

  • (String)

    JSON



14
15
16
17
18
19
20
21
# File 'lib/responders/wallaby/json_api_responder.rb', line 14

def to_json(*)
  json_options = { content_type: 'application/vnd.api+json', status: options[:status] }
  if exception?
    render json_options.merge(json: exception_details)
  else
    render json_options.merge(action_options)
  end
end