Skip to content
This repository

use correct variant of checking whether class is a singleton #4283

Merged
merged 1 commit into from over 2 years ago

2 participants

Sergey Nartimov Aaron Patterson
Sergey Nartimov
irb(main):008:0> klass = (class << Object.new; self end)
=> #<Class:#<Object:0x0000010084da68>>
irb(main):009:0> klass.ancestors.first == klass
=> false
irb(main):010:0> klass = Class.new
=> #<Class:0x000001010a5ff8>
irb(main):011:0> klass.ancestors.first == klass
=> true
Aaron Patterson tenderlove merged commit d1230a8 into from January 03, 2012
Aaron Patterson tenderlove closed this January 03, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 03, 2012
Sergey Nartimov use correct variant of checking whether class is a singleton 2f8a7ed
This page is out of date. Refresh to see the latest.
2  activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -110,6 +110,6 @@ def #{name}?
110 110
 
111 111
   private
112 112
   def singleton_class?
113  
-    !name || '' == name
  113
+    ancestors.first != self
114 114
   end
115 115
 end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.