aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-06-09 09:40:55 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2012-06-09 09:40:55 -0300
commitf9cfe9a4b2bf79c97d221c627a43103fbc0e5a58 (patch)
tree244f9107df0e8eb30acb94c8ca5e1d631383cc43 /activerecord
parentaa2bfd69f86acb7952015dc82ef01d8a36dc6efd (diff)
downloadrails-f9cfe9a4b2bf79c97d221c627a43103fbc0e5a58.tar.gz
rails-f9cfe9a4b2bf79c97d221c627a43103fbc0e5a58.tar.bz2
rails-f9cfe9a4b2bf79c97d221c627a43103fbc0e5a58.zip
Use each_with_object instead of each here
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb6
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb2
2 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index c445ec15dd..172026d150 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -149,9 +149,9 @@ module ActiveRecord
# Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
def attributes
- attrs = {}
- attribute_names.each { |name| attrs[name] = read_attribute(name) }
- attrs
+ attribute_names.each_with_object({}) { |name, attrs|
+ attrs[name] = read_attribute(name)
+ }
end
# Returns an <tt>#inspect</tt>-like string for the value of the
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index cb8f903474..a240c137ea 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -4,7 +4,7 @@ module ActiveRecord
attributes.map do |column, value|
table = default_table
- if value.is_a?(Hash)
+ if value.is_a?(Hash) && !value.empty?
table = Arel::Table.new(column, engine)
value.map { |k,v| build(table[k.to_sym], v) }
else