aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-07-31 11:55:24 +0200
committerXavier Noria <fxn@hashref.com>2010-07-31 11:55:24 +0200
commit3d7099891f07395ed889e7da9e13b3ff9244d539 (patch)
tree6a988362ec4a6b58c90a12e6b715cd6926a111ce /activerecord/lib/active_record/relation.rb
parent0e20e3ebc20250174867f33e0ad3972f7e7c76d0 (diff)
parentd3819daaac0d2f730f2b34af31700c914e697375 (diff)
downloadrails-3d7099891f07395ed889e7da9e13b3ff9244d539.tar.gz
rails-3d7099891f07395ed889e7da9e13b3ff9244d539.tar.bz2
rails-3d7099891f07395ed889e7da9e13b3ff9244d539.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index a8cea44c78..7962f52738 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -99,7 +99,7 @@ module ActiveRecord
if block_given?
to_a.many? { |*block_args| yield(*block_args) }
else
- @limit_value.present? ? to_a.many? : size > 1
+ @limit_value ? to_a.many? : size > 1
end
end
@@ -316,12 +316,12 @@ module ActiveRecord
def scope_for_create
@scope_for_create ||= begin
- @create_with_value || @where_values.inject({}) do |hash, where|
- if where.is_a?(Arel::Predicates::Equality)
- hash[where.operand1.name] = where.operand2.respond_to?(:value) ? where.operand2.value : where.operand2
- end
- hash
- end
+ @create_with_value || Hash[
+ @where_values.grep(Arel::Predicates::Equality).map { |where|
+ [where.operand1.name,
+ where.operand2.respond_to?(:value) ?
+ where.operand2.value : where.operand2]
+ }]
end
end