aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-21 11:26:19 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-21 11:26:19 -0800
commitfccc952ccd9ac05f26ebb3419999d7aa3e70e83d (patch)
tree32dcebe278d61cdf4ca71cfae7612487eba59990 /activesupport/lib/active_support
parent1a358e43d204ef86229418e76c55579220b41207 (diff)
parentf1b4cacbae71585be3f5dcb4c1bdd7c78ef3d590 (diff)
downloadrails-fccc952ccd9ac05f26ebb3419999d7aa3e70e83d.tar.gz
rails-fccc952ccd9ac05f26ebb3419999d7aa3e70e83d.tar.bz2
rails-fccc952ccd9ac05f26ebb3419999d7aa3e70e83d.zip
Merge pull request #4104 from lest/remove-1-8-code
remove Enumerable#each_with_object from core_ext as it is present in ruby 1.9
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb21
-rw-r--r--activesupport/lib/active_support/ruby/shim.rb4
2 files changed, 2 insertions, 23 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index ccd0e9692d..3f13468e4d 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -33,27 +33,6 @@ module Enumerable
collect { |element| element.send(method) }
end
- # Iterates over a collection, passing the current element *and* the
- # +memo+ to the block. Handy for building up hashes or
- # reducing collections down to one object. Examples:
- #
- # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
- # # => {'foo' => 'FOO', 'bar' => 'BAR'}
- #
- # *Note* that you can't use immutable objects like numbers, true or false as
- # the memo. You would think the following returns 120, but since the memo is
- # never changed, it does not.
- #
- # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
- #
- def each_with_object(memo)
- return to_enum :each_with_object, memo unless block_given?
- each do |element|
- yield element, memo
- end
- memo
- end unless [].respond_to?(:each_with_object)
-
# Convert an enumerable to a hash. Examples:
#
# people.index_by(&:login)
diff --git a/activesupport/lib/active_support/ruby/shim.rb b/activesupport/lib/active_support/ruby/shim.rb
index 608b3fe4b9..fc37ab84a3 100644
--- a/activesupport/lib/active_support/ruby/shim.rb
+++ b/activesupport/lib/active_support/ruby/shim.rb
@@ -3,7 +3,7 @@
#
# Date next_year, next_month
# DateTime to_date, to_datetime, xmlschema
-# Enumerable group_by, each_with_object, none?
+# Enumerable group_by, none?
# Process Process.daemon
# REXML security fix
# String ord
@@ -19,4 +19,4 @@ require 'active_support/core_ext/string/encoding'
require 'active_support/core_ext/rexml'
require 'active_support/core_ext/time/conversions'
require 'active_support/core_ext/file/path'
-require 'active_support/core_ext/module/method_names' \ No newline at end of file
+require 'active_support/core_ext/module/method_names'