Module: RactorRailsShim::Freezers::ClassIvarFreezer

Extended by:
RoleDefaults
Defined in:
lib/ractor_rails_shim/roles/freezers.rb

Class Method Summary collapse

Methods included from RoleDefaults

default_funnel, default_reassign_shareable_const, default_safe_const_get

Class Method Details

.callObject



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 89

def self.call
  return true unless defined?(::ActiveRecord::Base)
  ARModelWalker.each_model do |klass|
    klass.instance_variables.each do |ivar|
      val = klass.instance_variable_get(ivar)
      next if Ractor.shareable?(val)
      funnel.call("freeze AR ivar #{klass.name}#{ivar}") do
        Ractor.make_shareable(val)
      end
    end
  end
  true
end

.configure(funnel: nil) ⇒ Object



77
78
79
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 77

def self.configure(funnel: nil)
  @funnel = funnel
end

.funnelObject



85
86
87
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 85

def self.funnel
  @funnel || default_funnel
end

.reset_configurationObject



81
82
83
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 81

def self.reset_configuration
  @funnel = nil
end