aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-21 07:56:05 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-21 07:56:05 -0800
commit707eed72d33ab5048ad1545df4fc1f81652379af (patch)
treef62b74d9d619ca68c46b2ae63175d774eef418ba
parent2e9eb0a3ca88bf2fe402261ef684fb215edea215 (diff)
parenta57c6441a829a08d3ca341eecf4f1b4a5e43b909 (diff)
downloadrails-707eed72d33ab5048ad1545df4fc1f81652379af.tar.gz
rails-707eed72d33ab5048ad1545df4fc1f81652379af.tar.bz2
rails-707eed72d33ab5048ad1545df4fc1f81652379af.zip
Merge pull request #4103 from lest/remove-1-8-code
remove Kernel#singleton_class from core_ext as it is present in ruby 1.9
-rw-r--r--activesupport/lib/active_support/core_ext/kernel/singleton_class.rb7
-rw-r--r--activesupport/test/core_ext/kernel_test.rb7
-rw-r--r--railties/guides/source/active_support_core_extensions.textile13
3 files changed, 1 insertions, 26 deletions
diff --git a/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
index 33612155fb..9bbf1bbd73 100644
--- a/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
+++ b/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb
@@ -1,11 +1,4 @@
module Kernel
- # Returns the object's singleton class.
- def singleton_class
- class << self
- self
- end
- end unless respond_to?(:singleton_class) # exists in 1.9.2
-
# class_eval on an object acts like singleton_class.class_eval.
def class_eval(*args, &block)
singleton_class.class_eval(*args, &block)
diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb
index 995bc0751a..73a7179872 100644
--- a/activesupport/test/core_ext/kernel_test.rb
+++ b/activesupport/test/core_ext/kernel_test.rb
@@ -42,11 +42,6 @@ class KernelTest < Test::Unit::TestCase
assert_equal 1, silence_stderr { 1 }
end
- def test_singleton_class
- o = Object.new
- assert_equal class << o; self end, o.singleton_class
- end
-
def test_class_eval
o = Object.new
class << o; @x = 1; end
@@ -112,4 +107,4 @@ class KernelDebuggerTest < Test::Unit::TestCase
ensure
Object.send(:remove_const, "Rails")
end
-end \ No newline at end of file
+end
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 0296e27725..a5f9cd483b 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -177,19 +177,6 @@ end
NOTE: Defined in +active_support/core_ext/object/try.rb+.
-h4. +singleton_class+
-
-The method +singleton_class+ returns the singleton class of the receiver:
-
-<ruby>
-String.singleton_class # => #<Class:String>
-String.new.singleton_class # => #<Class:#<String:0x17a1d1c>>
-</ruby>
-
-WARNING: Fixnums and symbols have no singleton classes, +singleton_class+ raises +TypeError+ on them. Moreover, the singleton classes of +nil+, +true+, and +false+, are +NilClass+, +TrueClass+, and +FalseClass+, respectively.
-
-NOTE: Defined in +active_support/core_ext/kernel/singleton_class.rb+.
-
h4. +class_eval(*args, &block)+
You can evaluate code in the context of any object's singleton class using +class_eval+: