Class: ActiveResource::Errors
- Inherits:
-
ActiveModel::Errors
- Object
- ActiveModel::Errors
- ActiveResource::Errors
- Defined in:
- lib/active_resource/json_errors.rb
Instance Method Summary collapse
- #from_hash(messages, save_cache = false) ⇒ Object
-
#from_json(json, save_cache = false) ⇒ Object
Grabs errors from a json response.
Instance Method Details
#from_hash(messages, save_cache = false) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/active_resource/json_errors.rb', line 6 def from_hash(, save_cache = false) clear unless save_cache .each do |key,errors| errors.each do |error| add(key, error) end end end |
#from_json(json, save_cache = false) ⇒ Object
Grabs errors from a json response.
17 18 19 20 |
# File 'lib/active_resource/json_errors.rb', line 17 def from_json(json, save_cache = false) hash = ActiveSupport::JSON.decode(json)['errors'] || {} rescue {} from_hash hash, save_cache end |