Module: ActiveSupport::DescendantsTracker
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
::AbstractController::Base ,
ActionCable::Engine,
::ActionController::API ,
::ActionController::Base ,
::ActionController::Metal ,
ActionController::Railtie,
ActionDispatch::Railtie,
::ActionMailbox::Engine ,
::ActionMailer::Base ,
::ActionMailer::Preview ,
ActionMailer::Railtie,
::ActionText::Engine ,
ActionView::Railtie,
::ActionView::TestCase::TestController ,
ActiveJob::Railtie,
ActiveModel::Railtie,
::ActiveRecord::Base ,
ActiveRecord::Railtie,
ActiveStorage::Engine,
ActiveSupport::Railtie,
I18n::Railtie,
::Rails::Application ,
Rails::ApplicationController,
::Rails::Engine ,
::Rails::HealthController ,
Rails::InfoController,
Rails::MailersController,
::Rails::Railtie ,
::Rails::TestUnitRailtie ,
Rails::WelcomeController
| |
Defined in: | activesupport/lib/active_support/descendants_tracker.rb |
Overview
This module provides an internal implementation to track descendants which is faster than iterating through ObjectSpace
.
However Ruby 3.1 provide a fast native Class#subclasses method, so if you know your code won’t be executed on older rubies, including DescendantsTracker
does not provide any benefit.
Class Method Summary
-
.descendants(klass)
See additional method definition at line 104.
-
.subclasses(klass)
See additional method definition at line 100.
Instance Method Summary
-
#descendants
See additional method definition at line 109.
- #subclasses
Class Method Details
.descendants(klass)
See additional method definition at line 104.
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 163
def descendants(klass) klass.descendants end
.subclasses(klass)
See additional method definition at line 100.
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 158
def subclasses(klass) klass.subclasses end
Instance Method Details
#descendants
See additional method definition at line 109.
# File 'activesupport/lib/active_support/descendants_tracker.rb', line 179
def descendants subclasses = DescendantsTracker.reject!(self.subclasses) subclasses.concat(subclasses.flat_map(&:descendants)) end
#subclasses
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 175
def subclasses DescendantsTracker.subclasses(self) end