Skip to content

Commit

Permalink
Use each_with_object instead of each here
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jun 9, 2012
1 parent aa2bfd6 commit f9cfe9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/attribute_methods.rb
Expand Up @@ -149,9 +149,9 @@ def attribute_names

# 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
Expand Down
Expand Up @@ -4,7 +4,7 @@ def self.build_from_hash(engine, attributes, default_table)
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
Expand Down

0 comments on commit f9cfe9a

Please sign in to comment.