diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-04-13 00:04:40 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-13 20:25:28 +0800 |
commit | 733bfa63f5d8d3b963202b6d3e9f00b4db070b91 (patch) | |
tree | 10febe66946c850ce8e6bc0c9560d55d83b7a608 /activesupport | |
parent | 1f869114f5f671160653eb6f15d2850d82217fe5 (diff) | |
download | rails-733bfa63f5d8d3b963202b6d3e9f00b4db070b91.tar.gz rails-733bfa63f5d8d3b963202b6d3e9f00b4db070b91.tar.bz2 rails-733bfa63f5d8d3b963202b6d3e9f00b4db070b91.zip |
Remove `#among?` from Active Support
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.
It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/inclusion.rb | 9 | ||||
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/object/inclusion_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/transliterate_test.rb | 2 |
7 files changed, 6 insertions, 21 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index eb027795a8..163f1c932c 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,6 +1,6 @@ *Rails 3.1.0 (unreleased)* -* Add Object#in? to test if an object is included in another object, and Object#among? to test if an object is included in a list of objects which will be passed as arguments. [Prem Sichanugrist, Brian Morearty, John Reitano] +* Add Object#in? to test if an object is included in another object [Prem Sichanugrist, Brian Morearty, John Reitano] * LocalCache strategy is now a real middleware class, not an anonymous class posing for pictures. diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index bdef47a237..9936b33e22 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -21,7 +21,7 @@ module ActiveSupport end def clear(options = nil) - root_dirs = Dir.entries(cache_path).reject{|f| f.among?('.', '..')} + root_dirs = Dir.entries(cache_path).reject{|f| f.in?(['.', '..'])} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end @@ -162,7 +162,7 @@ module ActiveSupport # Delete empty directories in the cache. def delete_empty_directories(dir) return if dir == cache_path - if Dir.entries(dir).reject{|f| f.among?('.', '..')}.empty? + if Dir.entries(dir).reject{|f| f.in?(['.', '..'])}.empty? File.delete(dir) rescue nil delete_empty_directories(File.dirname(dir)) end diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 6a0bffb6d7..656cba625c 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -413,7 +413,7 @@ module ActiveSupport # CallbackChain. # def __update_callbacks(name, filters = [], block = nil) #:nodoc: - type = filters.first.among?(:before, :after, :around) ? filters.shift : :before + type = filters.first.in?([:before, :after, :around]) ? filters.shift : :before options = filters.last.is_a?(Hash) ? filters.pop : {} filters.unshift(block) if block diff --git a/activesupport/lib/active_support/core_ext/object/inclusion.rb b/activesupport/lib/active_support/core_ext/object/inclusion.rb index cf89288aed..cc7edc0f17 100644 --- a/activesupport/lib/active_support/core_ext/object/inclusion.rb +++ b/activesupport/lib/active_support/core_ext/object/inclusion.rb @@ -8,13 +8,4 @@ class Object def in?(another_object) another_object.include?(self) end - - # Returns true if this object is included in the argument list. Usage: - # - # username = "sikachu" - # username.among?("josevalim", "dhh", "wycats") # => false - # - def among?(*objects) - objects.include?(self) - end end diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 6b9120e51f..3d092529d6 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -345,7 +345,7 @@ module ActiveSupport end def duration_of_variable_length?(obj) - ActiveSupport::Duration === obj && obj.parts.any? {|p| p[0].among?(:years, :months, :days) } + ActiveSupport::Duration === obj && obj.parts.any? {|p| p[0].in?([:years, :months, :days]) } end end end diff --git a/activesupport/test/core_ext/object/inclusion_test.rb b/activesupport/test/core_ext/object/inclusion_test.rb index 9f2ace0ef7..382271d42d 100644 --- a/activesupport/test/core_ext/object/inclusion_test.rb +++ b/activesupport/test/core_ext/object/inclusion_test.rb @@ -30,12 +30,6 @@ class InTest < Test::Unit::TestCase assert !3.in?(s) end - def test_among - assert 1.among?(1,2,3) - assert !5.among?(1,2,3) - assert [1,2,3].among?([1,2,3], 2, [3,4,5]) - end - module A end class B diff --git a/activesupport/test/transliterate_test.rb b/activesupport/test/transliterate_test.rb index 90b40b5478..08e11d4f38 100644 --- a/activesupport/test/transliterate_test.rb +++ b/activesupport/test/transliterate_test.rb @@ -16,7 +16,7 @@ class TransliterateTest < Test::Unit::TestCase # create string with range of Unicode"s western characters with # diacritics, excluding the division and multiplication signs which for # some reason or other are floating in the middle of all the letters. - string = (0xC0..0x17E).to_a.reject {|c| c.among?(0xD7, 0xF7)}.pack("U*") + string = (0xC0..0x17E).to_a.reject {|c| c.in?([0xD7, 0xF7])}.pack("U*") string.each_char do |char| assert_match %r{^[a-zA-Z']*$}, ActiveSupport::Inflector.transliterate(string) end |