class Validatable::Errors
Public Instance Methods
full_messages → an_array_of_messages
click to toggle source
Returns an array containing the full list of error messages.
# File lib/errors.rb, line 53 def full_messages full_messages = [] errors.each_key do |attribute| errors[attribute].each do |msg| next if msg.nil? if attribute.to_s == "base" full_messages << msg else full_messages << humanize(attribute.to_s) + " " + msg end end end full_messages end
on(attribute)
click to toggle source
-
Returns nil, if no errors are associated with the specified
attribute
. -
Returns the error message, if one error is associated with the specified
attribute
. -
Returns an array of error messages, if more than one error is associated with the specified
attribute
.
# File lib/errors.rb, line 13 def on(attribute) return nil if errors[attribute.to_sym].nil? errors[attribute.to_sym].size == 1 ? errors[attribute.to_sym].first : errors[attribute.to_sym] end
raw(attribute)
click to toggle source
-
Returns an array of error messages associated with the specified
attribute
.
# File lib/errors.rb, line 38 def raw(attribute) errors[attribute.to_sym] end
replace(attribute)
click to toggle source
-
Replaces the errors value for the given
attribute
# File lib/errors.rb, line 31 def replace(attribute, value) errors[attribute.to_sym] = value end