Class: ClientErrorDetail
- Inherits:
-
Object
- Object
- ClientErrorDetail
- Defined in:
- lib/hyperion/types/client_error_detail.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
- ClientErrorCode
-
type of error.
-
#field ⇒ Object
readonly
- String, Nil
-
the location of the error within the resource.
-
#reason ⇒ Object
readonly
- Object, Nil
-
an explanation of the error.
-
#resource ⇒ Object
readonly
- String
-
the thing with the error.
-
#value ⇒ Object
readonly
- Object, Nil
-
the problematic data.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(code, resource, opts = {}) ⇒ ClientErrorDetail
constructor
A new instance of ClientErrorDetail.
-
#to_s ⇒ Object
make mongoid validations happy.
Constructor Details
#initialize(code, resource, opts = {}) ⇒ ClientErrorDetail
Returns a new instance of ClientErrorDetail.
10 11 12 13 14 15 16 |
# File 'lib/hyperion/types/client_error_detail.rb', line 10 def initialize(code, resource, opts={}) @code = canonical_code(code) @resource = resource @field = opts[:field] || '' @value = opts[:value] || '' @reason = opts[:reason] || '' end |
Instance Attribute Details
#code ⇒ Object (readonly)
- ClientErrorCode
-
type of error
4 5 6 |
# File 'lib/hyperion/types/client_error_detail.rb', line 4 def code @code end |
#field ⇒ Object (readonly)
- String, Nil
-
the location of the error within the resource
6 7 8 |
# File 'lib/hyperion/types/client_error_detail.rb', line 6 def field @field end |
#reason ⇒ Object (readonly)
- Object, Nil
-
an explanation of the error. usually a String.
8 9 10 |
# File 'lib/hyperion/types/client_error_detail.rb', line 8 def reason @reason end |
#resource ⇒ Object (readonly)
- String
-
the thing with the error
5 6 7 |
# File 'lib/hyperion/types/client_error_detail.rb', line 5 def resource @resource end |
#value ⇒ Object (readonly)
- Object, Nil
-
the problematic data
7 8 9 |
# File 'lib/hyperion/types/client_error_detail.rb', line 7 def value @value end |
Class Method Details
.from_attrs(attrs) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/hyperion/types/client_error_detail.rb', line 28 def self.from_attrs(attrs) code = ClientErrorCode.from(attrs['code']) resource = attrs['resource'] field = attrs['field'] value = attrs['value'] reason = attrs['reason'] self.new(code, resource, field: field, value: value, reason: reason) end |
Instance Method Details
#as_json ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/hyperion/types/client_error_detail.rb', line 18 def as_json { 'code' => code.value, 'resource' => resource, 'field' => field, 'value' => value, 'reason' => reason } end |
#empty? ⇒ Boolean
39 |
# File 'lib/hyperion/types/client_error_detail.rb', line 39 def empty?; false; end |
#to_s ⇒ Object
make mongoid validations happy
38 |
# File 'lib/hyperion/types/client_error_detail.rb', line 38 def to_s; reason; end |