Module: RactorRailsShim::Installer

Defined in:
lib/ractor_rails_shim/roles/installer.rb

Constant Summary collapse

NON_DISPATCHED_FRAMEWORK_PATCHES =

install*_patch methods called from OTHER install paths, not from the dispatcher. They are installed by their parent install method (e.g. _install_callbacks_nil_safe_patch and install_notifications_notifier patch are called from patch_execution_wrapper!; install_with_empty template_cache_patch is called from install via ActiveSupport.on_load). Excluded from auto-discovery so they aren't double-installed.

Ractor.make_shareable(%i[
  _install_callbacks_nil_safe_patch
  _install_notifications_notifier_patch
  _install_with_empty_template_cache_patch
].freeze)

Class Method Summary collapse

Class Method Details

.dispatch_all_framework_patchesObject

Auto-discover and call every install_patch singleton method on RactorRailsShim. Both prepare_for_ractors! (pre-worker boot) and make_app_shareable! (post-boot, pre-freeze) call this. Each install is idempotent (guarded by its own @_patched flag), so calling the full set at either point is a no-op for already-applied patches. The method table IS the registry — adding a new install_patch method to any patch file automatically includes it here without editing this dispatcher (Open/Closed).



80
81
82
83
84
85
86
87
# File 'lib/ractor_rails_shim/roles/installer.rb', line 80

def self.dispatch_all_framework_patches
  (RactorRailsShim.singleton_class.instance_methods(false) +
   RactorRailsShim.singleton_class.private_instance_methods(false))
    .map(&:to_sym)
    .select { |m| m.to_s.start_with?("_install_") && m.to_s.end_with?("_patch") }
    .reject { |m| m == :_install_all_framework_patches || NON_DISPATCHED_FRAMEWORK_PATCHES.include?(m) }
    .each { |m| RactorRailsShim.__send__(m) }
end

.installObject

Install all the patches. Safe to call multiple times (idempotent). Delegates the early-boot install_* calls to the RactorRailsShim facade (the methods live in their per-concern patch files).



57
58
59
60
61
62
63
64
65
66
# File 'lib/ractor_rails_shim/roles/installer.rb', line 57

def self.install
  RactorRailsShim._check_version_support
  RactorRailsShim::RunMode.resolve!
  strategy = RactorRailsShim::RunMode.thread? ?
    RactorRailsShim::InstallStrategy::Thread :
    RactorRailsShim::InstallStrategy::Ractor
  strategy.install
  @installed = true
  true
end

.installed?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/ractor_rails_shim/roles/installer.rb', line 68

def self.installed?
  @installed
end