Skip to content
Browse files

converting inject to each and map

[#4119 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 45c36ea commit 3789539916bcfbf82ee01f9aa35fca9f32049ea8 @tenderlove tenderlove committed with jeremy
Showing with 4 additions and 5 deletions.
  1. +4 −5 activerecord/lib/active_record/base.rb
View
9 activerecord/lib/active_record/base.rb
@@ -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)

0 comments on commit 3789539

Please sign in to comment.
Something went wrong with that request. Please try again.