Module: RactorRailsShim::Freezers::CacheWarmer
- Extended by:
- RoleDefaults
- Defined in:
- lib/ractor_rails_shim/roles/freezers.rb
Constant Summary
collapse
- WARMER_METHODS =
Ractor.make_shareable(%i[
timestamp_attributes_for_create_in_model
timestamp_attributes_for_update_in_model
all_timestamp_attributes_in_model
sequence_name
columns
column_names
attribute_names
column_defaults
symbol_column_to_string_name_hash
returning_columns_for_insert
yaml_encoder
attribute_types
].freeze)
Class Method Summary
collapse
default_funnel, default_reassign_shareable_const, default_safe_const_get
Class Method Details
.call ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 58
def self.call
return true unless defined?(::ActiveRecord::Base)
ARModelWalker.each_model(skip_abstract: true) do |klass|
WARMER_METHODS.each do |m|
next unless klass.respond_to?(m, true)
funnel.call("warm AR cache #{klass}##{m}") do
klass.send(m)
end
end
end
true
end
|
31
32
33
|
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 31
def self.configure(funnel: nil)
@funnel = funnel
end
|
.funnel ⇒ Object
39
40
41
|
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 39
def self.funnel
@funnel || default_funnel
end
|
.reset_configuration ⇒ Object
35
36
37
|
# File 'lib/ractor_rails_shim/roles/freezers.rb', line 35
def self.reset_configuration
@funnel = nil
end
|