Last active
November 10, 2016 21:37
-
-
Save rubyrider/6f80787ffaa0d033c94e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModel | |
class Errors | |
attr_accessor :error_code, :developer_message, :more_info | |
def add(attribute, message = :invalid, options = {}) | |
options.each { |k,v| instance_variable_set("@#{k}", v) } | |
message = normalize_message(attribute, message, options) | |
if exception = options[:strict] | |
exception = ActiveModel::StrictValidationFailed if exception == true | |
raise exception, full_message(attribute, message) | |
end | |
self[attribute] << message | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment