Skip to content

Commit

Permalink
converting inject to each and map
Browse files Browse the repository at this point in the history
[#4119 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
tenderlove authored and jeremy committed Mar 7, 2010
1 parent f6f75e8 commit 5a806f6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -2765,10 +2765,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 a hash of attributes before typecasting and deserialization.
Expand Down Expand Up @@ -3129,7 +3128,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 quoted_column_names(attributes = attributes_with_quotes)
Expand Down

0 comments on commit 5a806f6

Please sign in to comment.