diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-11-05 18:29:31 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-11-05 18:29:31 +0300 |
commit | 70ecf6c518c7d33724559795fc77e4307ba4d501 (patch) | |
tree | 2a7f4a30edd1fec646f8113895ae287152551ba1 /activemodel/lib | |
parent | 5cb2edce7fb19173a11d2cb03b50327f89e79291 (diff) | |
download | rails-70ecf6c518c7d33724559795fc77e4307ba4d501.tar.gz rails-70ecf6c518c7d33724559795fc77e4307ba4d501.tar.bz2 rails-70ecf6c518c7d33724559795fc77e4307ba4d501.zip |
use Array() instead flatten
* move ActiveModel::Errors tests to errors_test.rb
* add spec coverage for add_on_empty and add_on_blank
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 6882b59e26..c82d4f012c 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -308,7 +308,7 @@ module ActiveModel # person.errors.messages # # => {:name=>["can't be empty"]} def add_on_empty(attributes, options = {}) - [attributes].flatten.each do |attribute| + Array(attributes).each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) is_empty = value.respond_to?(:empty?) ? value.empty? : false add(attribute, :empty, options) if value.nil? || is_empty @@ -322,7 +322,7 @@ module ActiveModel # person.errors.messages # # => {:name=>["can't be blank"]} def add_on_blank(attributes, options = {}) - [attributes].flatten.each do |attribute| + Array(attributes).each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) add(attribute, :blank, options) if value.blank? end |