提交 f9cfe9a4 编写于 作者: S Santiago Pastorino

Use each_with_object instead of each here

上级 aa2bfd69
......@@ -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?
table = Arel::Table.new(column, engine)
value.map { |k,v| build(table[k.to_sym], v) }
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册