aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-05-17 01:55:56 +0430
committerXavier Noria <fxn@hashref.com>2010-05-17 23:03:16 +0200
commit8c5e1652c7d1343a4b4acbc10bbcb59e202bf37d (patch)
tree214d5f62de7775bc9214778ef76ded3a4ccbed4b /activesupport
parentf09d8f3e68ca7cf35a7905b00f85b84c3839c803 (diff)
downloadrails-8c5e1652c7d1343a4b4acbc10bbcb59e202bf37d.tar.gz
rails-8c5e1652c7d1343a4b4acbc10bbcb59e202bf37d.tar.bz2
rails-8c5e1652c7d1343a4b4acbc10bbcb59e202bf37d.zip
Renames Array#rand -> Array#random_element
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/array/random_access.rb12
-rw-r--r--activesupport/test/core_ext/array_ext_test.rb4
3 files changed, 3 insertions, 15 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 7afd9926b5..7d00211ea1 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.0.0 [beta 4/release candidate] (unreleased)*
+* Renames Array#rand -> Array#random_element. [Santiago Pastorino, Rizwan Reza]
+
* Defines prev_(month|year) in Date and Time, and deprecates last_(month|year). [fxn]
* Aliases Date#sunday to Date#end_of_week. [fxn]
diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb
index 5338836b29..67c322daea 100644
--- a/activesupport/lib/active_support/core_ext/array/random_access.rb
+++ b/activesupport/lib/active_support/core_ext/array/random_access.rb
@@ -1,16 +1,6 @@
class Array
- # This method is deprecated because it masks Kernel#rand within the Array class itself,
- # which may be used by a 3rd party library extending Array in turn. See
- #
- # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555
- #
- def rand # :nodoc:
- ActiveSupport::Deprecation.warn "Array#rand is deprecated, use random_element instead", caller
- random_element
- end
-
# Returns a random element from the array.
def random_element
self[Kernel.rand(length)]
end
-end
+end \ No newline at end of file
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index ebd6806416..1f7cdb8ec1 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -368,10 +368,6 @@ class ArrayExtRandomTests < ActiveSupport::TestCase
Kernel.expects(:rand).with(3).returns(1)
assert_equal 2, [1, 2, 3].random_element
end
-
- def test_deprecated_rand_on_array
- assert_deprecated { [].rand }
- end
end
class ArrayWrapperTests < Test::Unit::TestCase