Class: MedpassResourceApi::ErrorResult

Inherits:
Object
  • Object
show all
Defined in:
lib/medpass_resource_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ ErrorResult

Returns a new instance of ErrorResult.



171
172
173
# File 'lib/medpass_resource_api.rb', line 171

def initialize(error)
  @raw_errors = JSON.parse(error.response.body)
end

Instance Attribute Details

#raw_errorsObject (readonly)

Returns the value of attribute raw_errors.



170
171
172
# File 'lib/medpass_resource_api.rb', line 170

def raw_errors
  @raw_errors
end

Instance Method Details

#errorsObject



183
184
185
# File 'lib/medpass_resource_api.rb', line 183

def errors
  self.raw_errors
end

#errors_on(field) ⇒ Object



175
176
177
# File 'lib/medpass_resource_api.rb', line 175

def errors_on(field)
  @raw_errors[field.to_s] rescue nil
end

#first_error_on(field) ⇒ Object



179
180
181
# File 'lib/medpass_resource_api.rb', line 179

def first_error_on(field)
  errors_on(field).first rescue errors_on(field)
end