Module: RactorRailsShim::StorageStrategy::Thread
- Defined in:
- lib/ractor_rails_shim/foundation/storage_strategy.rb
Overview
Thread-mode strategy: ancestor-walk + CLASS_ATTR_VALUES. The key the
caller passes is the FIXED namespaced key (:"ractor_rails_shim_class_ attr_<oid>_<name>"); the Thread strategy reads via ancestor-walk using
each ancestor's object_id, and writes keyed by the receiver's
object_id. The namespaced_name suffix is extracted from the key so
the ancestor walk can rebuild per-ancestor keys.
Class Method Summary collapse
-
.lookup(owner, key, missing_default) ⇒ Object
The missing_default is inlined into the eval'd heredoc by the caller as the actual VALUE (the heredoc interpolates the expression, so the strategy receives the evaluated object, not a source string).
-
.replay_callbacks!(context, kind, &block) ⇒ Object
Thread mode always replays captured callbacks.
-
.replay_callbacks?(callbacks) ⇒ Boolean
Thread mode: the eager-load class_attribute leak corrupts __callbacks, so ALWAYS replay the captured symbolic filters (ignoring __callbacks entirely).
- .store(owner, key, value) ⇒ Object
Class Method Details
.lookup(owner, key, missing_default) ⇒ Object
The missing_default is inlined into the eval'd heredoc by the caller as the actual VALUE (the heredoc interpolates the expression, so the strategy receives the evaluated object, not a source string). The ancestor walk rebuilds each ancestor's key from its object_id + the namespaced suffix.
126 127 128 129 130 131 132 133 |
# File 'lib/ractor_rails_shim/foundation/storage_strategy.rb', line 126 def lookup(owner, key, missing_default) suffix = _suffix_from_key(key) owner.ancestors.each do |anc| k = :"ractor_rails_shim_class_attr_#{anc.object_id}_#{suffix}" return RactorRailsShim::Registry.class_attr_values[k] if RactorRailsShim::Registry.class_attr_values.key?(k) end missing_default end |
.replay_callbacks!(context, kind, &block) ⇒ Object
Thread mode always replays captured callbacks. Delegates to the shared replay_callbacks! implementation on the Ractor strategy (same logic, different trigger).
153 154 155 |
# File 'lib/ractor_rails_shim/foundation/storage_strategy.rb', line 153 def replay_callbacks!(context, kind, &block) RactorRailsShim::StorageStrategy::Ractor.replay_callbacks!(context, kind, &block) end |
.replay_callbacks?(callbacks) ⇒ Boolean
Thread mode: the eager-load class_attribute leak corrupts __callbacks, so ALWAYS replay the captured symbolic filters (ignoring __callbacks entirely). The "on-empty" gate is unreachable (the "always" path runs first); provided for contract parity.
146 147 148 |
# File 'lib/ractor_rails_shim/foundation/storage_strategy.rb', line 146 def replay_callbacks?(callbacks) false end |
.store(owner, key, value) ⇒ Object
135 136 137 138 139 |
# File 'lib/ractor_rails_shim/foundation/storage_strategy.rb', line 135 def store(owner, key, value) suffix = _suffix_from_key(key) RactorRailsShim::Registry.class_attr_values[:"ractor_rails_shim_class_attr_#{owner.object_id}_#{suffix}"] = value value end |