Sha256: 3907c336997d7ce104bbd1d71bb64b0b0fcae6c2a643868a6b7c76bbaec05c1a
Contents?: true
Size: 758 Bytes
Versions: 1
Compression:
Stored size: 758 Bytes
Contents
require "active_model" # ApiClient::Errors provide extra functionality to ActiveModel::Errors. class ApiClient::Errors < ActiveModel::Errors # Add serveral errors from a hash to the object. # # @return [ApiClient::Errors] The Error object. def add_errors(errors = {}) errors.each do |key, value| self.set(key, value) end self end # Create a hash of attributes with unique validation error messages. # # Example: # user.errors.unique_messages #=> { :name => [ can't be empty and is invalid ]} # # @return [Hash] The hash of attributes with a unique error message. def unique_messages errors = {} to_hash.each do |attribute, messages| errors[attribute] = messages.join(" and ") end errors end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api-client-1.5.1 | lib/api-client/errors.rb |