Skip to content
This repository
Browse code

converting inject to each and map

[#4119 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit 5a806f67591978a4f65af12ddc3595c7c356b49e 1 parent f6f75e8
Aaron Patterson tenderlove authored jeremy committed

Showing 1 changed file with 4 additions and 5 deletions. Show diff stats Hide diff stats

  1. +4 5 activerecord/lib/active_record/base.rb
9 activerecord/lib/active_record/base.rb
@@ -2765,10 +2765,9 @@ def attributes=(new_attributes, guard_protected_attributes = true)
2765 2765
2766 2766 # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
2767 2767 def attributes
2768   - self.attribute_names.inject({}) do |attrs, name|
2769   - attrs[name] = read_attribute(name)
2770   - attrs
2771   - end
  2768 + attrs = {}
  2769 + attribute_names.each { |name| attrs[name] = read_attribute(name) }
  2770 + attrs
2772 2771 end
2773 2772
2774 2773 # Returns a hash of attributes before typecasting and deserialization.
@@ -3129,7 +3128,7 @@ def find_parameter_position(multiparameter_name)
3129 3128
3130 3129 # Returns a comma-separated pair list, like "key1 = val1, key2 = val2".
3131 3130 def comma_pair_list(hash)
3132   - hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ")
  3131 + hash.map { |k,v| "#{k} = #{v}" }.join(", ")
3133 3132 end
3134 3133
3135 3134 def quoted_column_names(attributes = attributes_with_quotes)

0 comments on commit 5a806f6

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