6
def_delegators :errors, :clear, :each, :each_pair, :empty?, :length, :size
8
# call-seq: on(attribute)
10
# * Returns nil, if no errors are associated with the specified +attribute+.
11
# * Returns the error message, if one error is associated with the specified +attribute+.
12
# * Returns an array of error messages, if more than one error is associated with the specified +attribute+.
14
return nil if errors[attribute.to_sym].nil?
15
errors[attribute.to_sym].size == 1 ? errors[attribute.to_sym].first : errors[attribute.to_sym]
18
def add(attribute, message) #:nodoc:
19
errors[attribute.to_sym] = [] if errors[attribute.to_sym].nil?
20
errors[attribute.to_sym] << message
23
def merge!(errors) #:nodoc:
24
errors.each_pair{|k, v| add(k,v)}
28
# call-seq: replace(attribute)
30
# * Replaces the errors value for the given +attribute+
31
def replace(attribute, value)
32
errors[attribute.to_sym] = value
35
# call-seq: raw(attribute)
37
# * Returns an array of error messages associated with the specified +attribute+.
39
errors[attribute.to_sym]
47
errors.values.flatten.size
50
# call-seq: full_messages -> an_array_of_messages
52
# Returns an array containing the full list of error messages.
56
errors.each_key do |attribute|
57
errors[attribute].each do |msg|
60
if attribute.to_s == "base"
63
full_messages << humanize(attribute.to_s) + " " + msg
70
def humanize(lower_case_and_underscored_word) #:nodoc:
71
lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
b'\\ No newline at end of file'