mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
converting inject to each and map
[#4119 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
committed by
Jeremy Kemper
parent
45c36ea096
commit
3789539916
@@ -2001,10 +2001,9 @@ module ActiveRecord #:nodoc:
|
||||
|
||||
# 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 @@ module ActiveRecord #:nodoc:
|
||||
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user