Class: Unit::UnitError

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/errors/unit_error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ UnitError

Create a new UnitError

Parameters:



12
13
14
# File 'lib/unit/errors/unit_error.rb', line 12

def initialize(errors)
  @errors = errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/unit/errors/unit_error.rb', line 8

def errors
  @errors
end

Class Method Details

.from_json_api(response) ⇒ UnitError

Creates a new UnitError from given response.

Parameters:

  • response (HTTP::Response)

    The response returned from Unit’s API

Returns:

  • (UnitError)

    a new UnitError populated with values taken from the response



19
20
21
# File 'lib/unit/errors/unit_error.rb', line 19

def self.from_json_api(response)
  new((response.body["errors"] || []).map { |error| UnitErrorPayload.from_json_api(error) })
end