Skip to content

Commit e9ff835

Browse files
committed
Try dropping the singleton_class? redefinition
1 parent 7bdda53 commit e9ff835

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

lib/robe/core_ext.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ class Module
33
alias_method :__name__, :name
44
end
55

6-
if method_defined?(:singleton_class?)
7-
alias_method :__singleton_class__?, :singleton_class?
8-
else
9-
def __singleton_class__?
10-
self != Class && ancestors.first != self
11-
end
12-
end
13-
146
unless method_defined?(:__singleton_class__)
157
alias_method :__singleton_class__, :singleton_class
168
end

lib/robe/sash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def find_method_owner(mod, inst, sym)
5050

5151
def method_spec(method)
5252
owner, inst = method.owner, nil
53-
if owner.__singleton_class__?
53+
if owner.singleton_class?
5454
# FIXME: Use https://docs.ruby-lang.org/en/3.2/Class.html#method-i-attached_object
5555
name = owner.to_s[/Class:([A-Z][^\(> ]*)/, 1] # defined in an eigenclass
5656
elsif name = name_cache[owner]

lib/robe/sash/includes_tracker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.maybe_scan
2727

2828
ObjectSpace.each_object(Module) do |cl|
2929
next unless cl.respond_to?(:included_modules)
30-
next if cl.__singleton_class__?
30+
next if cl.singleton_class?
3131
cl.included_modules.each { |mod| includers[mod] << [cl, true] }
3232
sc = cl.__singleton_class__
3333
sc.included_modules.each { |mod| includers[mod] << [cl, nil] }

lib/robe/type_space.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ def scan_with(scanner)
3737
unless instance
3838
singleton_ancestors = obj.singleton_class.ancestors
3939

40-
if RUBY_VERSION >= "2.1.0"
41-
# Ruby 2.1 includes all singletons in the ancestors chain
42-
singleton_ancestors.reject!(&:__singleton_class__?)
43-
end
40+
# Ruby 2.1+ includes all singletons in the ancestors chain
41+
singleton_ancestors.reject!(&:singleton_class?)
4442

4543
scanner.scan(singleton_ancestors, true, false)
4644
end

lib/robe/visor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Visor
88
SearchError = Class.new(StandardError)
99

1010
def each_object(*args)
11-
ObjectSpace.each_object(*args).reject { |m| m.__singleton_class__? }
11+
ObjectSpace.each_object(*args).reject { |m| m.singleton_class? }
1212
end
1313

1414
# Returns descendants and (modules only) also includers.

0 commit comments

Comments
 (0)