Class: Ralph::Config
- Inherits:
-
Object
- Object
- Ralph::Config
- Defined in:
- lib/ralph/config.rb
Constant Summary collapse
- OPTIONS =
Single source of truth for config option names and their defaults. Use a lambda for mutable defaults to avoid shared state.
{ prompt: -> { PromptTemplate.new("") }, min_iterations: 1, max_iterations: 0, completion_promise: "COMPLETE", tasks_mode: false, task_promise: "READY_FOR_NEXT_TASK", model: "", chosen_agent: "opencode", disable_plugins: false, allow_all_permissions: true, stream_output: true, verbose_tools: false, }.freeze
Instance Attribute Summary collapse
-
#current_pid ⇒ Object
Runtime state (not constructor args, not in to_h).
-
#stopping ⇒ Object
Runtime state (not constructor args, not in to_h).
Instance Method Summary collapse
-
#initialize(**opts) ⇒ Config
constructor
A new instance of Config.
-
#to_h ⇒ Object
Returns a hash of options suitable for passing to Loop#call.
Constructor Details
#initialize(**opts) ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 |
# File 'lib/ralph/config.rb', line 25 def initialize(**opts) OPTIONS.each do |key, default| value = opts.fetch(key) { default.respond_to?(:call) ? default.call : default } instance_variable_set(:"@#{key}", value) end @current_pid = nil @stopping = false end |
Instance Attribute Details
#current_pid ⇒ Object
Runtime state (not constructor args, not in to_h).
23 24 25 |
# File 'lib/ralph/config.rb', line 23 def current_pid @current_pid end |
#stopping ⇒ Object
Runtime state (not constructor args, not in to_h).
23 24 25 |
# File 'lib/ralph/config.rb', line 23 def stopping @stopping end |
Instance Method Details
#to_h ⇒ Object
Returns a hash of options suitable for passing to Loop#call. Excludes runtime state (current_pid, stopping).
36 37 38 |
# File 'lib/ralph/config.rb', line 36 def to_h OPTIONS.keys.map { |k| [k, send(k)] }.to_h end |