class ActiveResource::Errors

Public Instance Methods

from_hash(messages, save_cache = false) click to toggle source
# File lib/active_resource/json_errors.rb, line 5
def from_hash(messages, save_cache = false)
  clear unless save_cache

  messages.each do |key,errors|
    errors.each do |error|
      add(key, error)
    end
  end
end
from_json(json, save_cache = false) click to toggle source

Grabs errors from a json response.

# File lib/active_resource/json_errors.rb, line 16
def from_json(json, save_cache = false)
  hash = ActiveSupport::JSON.decode(json)['errors'] || {} rescue {}
  from_hash hash, save_cache
end