aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-11 10:04:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-11 10:04:37 +0000
commitc0e618cf6f7f6c4a474e4ed30e05c16620615b9a (patch)
tree23480589b45d58dcfe3c2b9ab5e02af6a05056a1
parent57070277b420819b9bf0980e1a794a587f31dff6 (diff)
downloadrails-c0e618cf6f7f6c4a474e4ed30e05c16620615b9a.tar.gz
rails-c0e618cf6f7f6c4a474e4ed30e05c16620615b9a.tar.bz2
rails-c0e618cf6f7f6c4a474e4ed30e05c16620615b9a.zip
Refactored to a more readble form #1813
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-xactiverecord/lib/active_record/associations.rb4
-rwxr-xr-xactiverecord/lib/active_record/validations.rb2
2 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index df9c66aa08..bfa932c5b8 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -692,9 +692,7 @@ module ActiveRecord
else
records_to_save = association.select{ |record| record.new_record? }
end
- records_to_save.inject(true) do |result,record|
- result &&= record.valid?
- end
+ records_to_save.all? { |record| record.valid? }
end
end_eval
end
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index ecc192247a..6481e37a25 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -589,7 +589,7 @@ module ActiveRecord
validates_each(attr_names, configuration) do |record, attr_name, value|
record.errors.add(attr_name, configuration[:message]) unless
- (value.is_a?(Array) ? value : [value]).inject(true) { |memo, r| (r.nil? or r.valid?) and memo }
+ (value.is_a?(Array) ? value : [value]).all? { |r| r.nil? or r.valid? }
end
end