Sha256: 576cc34736338a0f2290697775293c2d313c801ef92a8d4e4e4a9bc7af94704d
Contents?: true
Size: 753 Bytes
Versions: 8
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true require 'active_resource/base' module ActiveResource class Errors < ActiveModel::Errors def from_json(json, save_cache = false) data = begin ActiveSupport::JSON.decode(json)['errors'] || {} rescue {} end case data when String from_string(data, save_cache) else from_hash(data, save_cache) end end 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 def from_string(error, save_cache = false) clear unless save_cache add(:base, error) end end end
Version data entries
8 entries across 8 versions & 2 rubygems