提交 37895399 编写于 作者: A Aaron Patterson 提交者: Jeremy Kemper

converting inject to each and map

[#4119 state:committed]
Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 45c36ea0
......@@ -2001,10 +2001,9 @@ def attributes=(new_attributes, guard_protected_attributes = true)
# Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
def attributes
self.attribute_names.inject({}) do |attrs, name|
attrs[name] = read_attribute(name)
attrs
end
attrs = {}
attribute_names.each { |name| attrs[name] = read_attribute(name) }
attrs
end
# Returns an <tt>#inspect</tt>-like string for the value of the
......@@ -2348,7 +2347,7 @@ def find_parameter_position(multiparameter_name)
# Returns a comma-separated pair list, like "key1 = val1, key2 = val2".
def comma_pair_list(hash)
hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ")
hash.map { |k,v| "#{k} = #{v}" }.join(", ")
end
def quote_columns(quoter, hash)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册