Class: JsonAPIObjectMapper::Parser::Document
- Inherits:
-
Object
- Object
- JsonAPIObjectMapper::Parser::Document
- Includes:
- Errors
- Defined in:
- lib/jsonapi-object-mapper/parser/document.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#includes ⇒ Object
Returns the value of attribute includes.
Attributes included from Errors
Instance Method Summary collapse
- #deserialize_errors! ⇒ Object
-
#initialize(document) ⇒ Document
constructor
A new instance of Document.
Methods included from Errors
Constructor Details
#initialize(document) ⇒ Document
Returns a new instance of Document.
13 14 15 16 17 18 |
# File 'lib/jsonapi-object-mapper/parser/document.rb', line 13 def initialize(document) @document = (document.is_a?(String) ? ::Oj.load(document) : document).freeze @includes = IncludedResources.load(@document["included"]) @errors = deserialize_errors!.freeze freeze end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
11 12 13 |
# File 'lib/jsonapi-object-mapper/parser/document.rb', line 11 def document @document end |
#includes ⇒ Object
Returns the value of attribute includes.
11 12 13 |
# File 'lib/jsonapi-object-mapper/parser/document.rb', line 11 def includes @includes end |
Instance Method Details
#deserialize_errors! ⇒ Object
20 21 22 23 |
# File 'lib/jsonapi-object-mapper/parser/document.rb', line 20 def deserialize_errors! return [] unless @document.key?("errors") Set.new(@document["errors"]) { |error| OpenStruct.new(error) } end |