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



104
105
106
# File 'lib/ractor/cache/strategy.rb', line 104

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

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



108
109
110
111
112
113
114
115
116
117
# File 'lib/ractor/cache/strategy.rb', line 108

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

  raise
end