Class: SimpleJsonapi::Node::Document::Errors

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_jsonapi/node/document/errors.rb

Overview

Represents a JSONAPI document containing a collection of errors.

Instance Attribute Summary collapse

Attributes inherited from Base

#extras, #fields_spec, #include_spec, #root_node, #serializer, #serializer_inferrer, #sort_spec

Instance Method Summary collapse

Methods inherited from Base

#append_included_resource, #as_jsonapi, #included_resource?

Methods inherited from Base

#as_jsonapi

Constructor Details

#initialize(errors:, **options) ⇒ Errors

Returns a new instance of Errors.

Parameters:

  • errors (Array<Object>)
  • options

    see Base#initialize for additional parameters



10
11
12
13
14
15
# File 'lib/simple_jsonapi/node/document/errors.rb', line 10

def initialize(errors:, **options)
  super

  @errors = Array.wrap(errors)
  @errors_node = build_child_node(SimpleJsonapi::Node::Errors, errors: @errors)
end

Instance Attribute Details

#errorsArray<Object> (readonly)

Returns:

  • (Array<Object>)


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/simple_jsonapi/node/document/errors.rb', line 5

class Errors < Base
  attr_reader :errors

  # @param errors [Array<Object>]
  # @param options see {Node::Document::Base#initialize} for additional parameters
  def initialize(errors:, **options)
    super

    @errors = Array.wrap(errors)
    @errors_node = build_child_node(SimpleJsonapi::Node::Errors, errors: @errors)
  end
end