aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-03-06 15:30:43 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2010-03-06 20:31:50 -0800
commit3789539916bcfbf82ee01f9aa35fca9f32049ea8 (patch)
treee98c614aa982e07050506bdb4ef0da6867179ff9 /activerecord/lib/active_record/base.rb
parent45c36ea0961d015bf040043c7ab2ac2069d3b92f (diff)
downloadrails-3789539916bcfbf82ee01f9aa35fca9f32049ea8.tar.gz
rails-3789539916bcfbf82ee01f9aa35fca9f32049ea8.tar.bz2
rails-3789539916bcfbf82ee01f9aa35fca9f32049ea8.zip
converting inject to each and map
[#4119 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index cd67490573..042a67b490 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -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)