Module: RactorRailsShim::FallbackBuilder::ShareableCopy

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

Overview

Dispatch table for shareable copies of mutable default containers. Replaces the case/if type-switch in FallbackBuilder.shareable_copy and GlobalConstantFreezer.call. Adding a new shareable-copy type is a one-line table entry (Issue #40, POODR ยง5b).

Constant Summary collapse

COPIERS =
{
  Hash  => ->(v) { v.dup },
  Array => ->(v) { v.dup },
}.freeze

Class Method Summary collapse

Class Method Details

.call(val) ⇒ Object



327
328
329
330
# File 'lib/ractor_rails_shim/roles/fallback_builder.rb', line 327

def self.call(val)
  copier = COPIERS.find { |klass, _| val.is_a?(klass) }&.last
  copier ? copier.call(val) : val
end