class ClientErrorDetail

Attributes

code[R]
field[R]
reason[R]
resource[R]
value[R]

Public Class Methods

from_attrs(attrs) click to toggle source
# 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
new(code, resource, opts={}) click to toggle source
# 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

Public Instance Methods

as_json() click to toggle source
# 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?() click to toggle source
# File lib/hyperion/types/client_error_detail.rb, line 39
def empty?; false; end
to_s() click to toggle source

make mongoid validations happy

# File lib/hyperion/types/client_error_detail.rb, line 38
def to_s; reason; end

Private Instance Methods

canonical_code(x) click to toggle source
# File lib/hyperion/types/client_error_detail.rb, line 43
def canonical_code(x)
  x.is_a?(Symbol) ? ClientErrorCode.from_symbol(x) : ClientErrorCode.from(x)
end