Permalink
Browse files

Use each_with_object instead of each here

  • Loading branch information...
1 parent aa2bfd6 commit f9cfe9a4b2bf79c97d221c627a43103fbc0e5a58 @spastorino spastorino committed Jun 9, 2012
@@ -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
@@ -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?
@spastorino
spastorino Jun 9, 2012 Ruby on Rails member

Ouch, this was committed by accident

@spastorino
spastorino Jun 9, 2012 Ruby on Rails member

Fixed 6bd729e

table = Arel::Table.new(column, engine)
value.map { |k,v| build(table[k.to_sym], v) }
else

0 comments on commit f9cfe9a

Please sign in to comment.