Module: RactorRailsShim::Patches::HashComputeIfAbsent
- Defined in:
- lib/ractor_rails_shim/patches/hash_compute_if_absent.rb
Defined Under Namespace
Modules: Overrides
Class Method Summary collapse
-
.install ⇒ Object
Install the
Hash#compute_if_absentpatch. -
.installed? ⇒ Boolean
Reader for the idempotency flag.
-
.reset_installed_for_test! ⇒ Object
Test seam: reset the idempotency flag between specs.
Class Method Details
.install ⇒ Object
Install the Hash#compute_if_absent patch. Idempotent — the
@installed flag lives on this object, not on the facade.
Returns true once installed (and on subsequent no-op calls).
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ractor_rails_shim/patches/hash_compute_if_absent.rb', line 72 def self.install @mutex.synchronize do return true if @installed if ::Hash.method_defined?(:compute_if_absent) @installed = true return true end ::Hash.prepend(Overrides) @installed = true end true end |
.installed? ⇒ Boolean
Reader for the idempotency flag. Owned by this role object.
86 87 88 |
# File 'lib/ractor_rails_shim/patches/hash_compute_if_absent.rb', line 86 def self.installed? @installed end |
.reset_installed_for_test! ⇒ Object
Test seam: reset the idempotency flag between specs. Production code never calls this — the prepend is permanent, but specs that re-run install need a clean slate for assertion purposes.
93 94 95 |
# File 'lib/ractor_rails_shim/patches/hash_compute_if_absent.rb', line 93 def self.reset_installed_for_test! @mutex.synchronize { @installed = false } end |