Module: Omakase::Strategies

Defined in:
lib/omakase/strategies.rb,
lib/omakase/strategies/predict.rb,
lib/omakase/strategies/code_act.rb

Overview

How a generation method gets its answer. Named ones are looked up by symbol (strategy :predict); anything that responds to call(request) also works, which is the seam for your own.

Defined Under Namespace

Modules: CodeAct, Predict

Class Method Summary collapse

Class Method Details

.fetch(strategy) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/omakase/strategies.rb', line 10

def fetch(strategy)
  return strategy if strategy.respond_to?(:call)

  const_get(strategy.to_s.split("_").map(&:capitalize).join)
rescue NameError
  raise Error, "unknown strategy #{strategy.inspect}"
end