Module: Ractor::Cache::Strategy

Defined in:
lib/ractor/cache/strategy.rb

Defined Under Namespace

Classes: Base, Disable, Prebuild

Class Method Summary collapse

Class Method Details

.[](kind) ⇒ Object



97
98
99
# File 'lib/ractor/cache/strategy.rb', line 97

def [](kind)
  MAP.fetch(kind)
end

.new(strategy = nil, to_cache:) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'lib/ractor/cache/strategy.rb', line 101

def new(
  strategy = nil,    # => (:prebuild | :disable)?
  to_cache:          # => UnboundMethod
)                    # => Strategy
  self[strategy || :prebuild].new(to_cache)
rescue ArgumentError
  return new(:prebuild, to_cache: to_cache) if strategy == nil

  raise
end