Class: JSONAPI::ResponseDocument
- Inherits:
-
Object
- Object
- JSONAPI::ResponseDocument
- Defined in:
- lib/jsonapi/response_document.rb
Instance Method Summary collapse
- #contents ⇒ Object
-
#initialize(operation_results, serializer, options = {}) ⇒ ResponseDocument
constructor
A new instance of ResponseDocument.
- #status ⇒ Object
Constructor Details
#initialize(operation_results, serializer, options = {}) ⇒ ResponseDocument
Returns a new instance of ResponseDocument.
3 4 5 6 7 8 9 |
# File 'lib/jsonapi/response_document.rb', line 3 def initialize(operation_results, serializer, = {}) @operation_results = operation_results @serializer = serializer @options = @key_formatter = @options.fetch(:key_formatter, JSONAPI.configuration.key_formatter) end |
Instance Method Details
#contents ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jsonapi/response_document.rb', line 11 def contents hash = results_to_hash = hash.merge!(meta: ) unless .empty? links = top_level_links hash.merge!(links: links) unless links.empty? hash end |
#status ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/jsonapi/response_document.rb', line 23 def status if @operation_results.has_errors? @operation_results.all_errors[0].status else @operation_results.results[0].code end end |