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::PwaController,
::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
Instance Method Summary
Class Method Details
.descendants(klass)
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 102
def descendants(klass) klass.descendants end
.subclasses(klass)
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 98
def subclasses(klass) klass.subclasses end
Instance Method Details
#descendants
[ GitHub ]# File 'activesupport/lib/active_support/descendants_tracker.rb', line 107
def descendants subclasses = DescendantsTracker.reject!(self.subclasses) subclasses.concat(subclasses.flat_map(&:descendants)) end