mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use the native Class#descendants
if available
Ruby 3.1 is very likely to ship with a native implementation of `Class#descendants` that doesn't need to iterate over ObjectSpace. So we should use it if available. Ref: https://bugs.ruby-lang.org/issues/14394 Ref: https://github.com/ruby/ruby/pull/4974
This commit is contained in:
parent
bd400b479b
commit
d8936b755d
1 changed files with 1 additions and 1 deletions
|
@ -18,7 +18,7 @@ class Class
|
|||
ObjectSpace.each_object(singleton_class).reject do |k|
|
||||
k.singleton_class? || k == self
|
||||
end
|
||||
end
|
||||
end unless method_defined?(:descendants) # RUBY_VERSION >= "3.1"
|
||||
|
||||
# Returns an array with the direct children of +self+.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue