Class: OllamaChat::Switches::CombinedSwitch

Inherits:
Object
  • Object
show all
Includes:
CheckSwitch
Defined in:
lib/ollama_chat/switches.rb

Overview

A switch class that manages a boolean state based on a proc value.

The CombinedSwitch class provides a way to manage a boolean configuration option where the state is determined by evaluating a stored proc. This is useful for complex conditions that depend on multiple factors or dynamic values, such as combining multiple switch states into a single effective state.

Examples:

Checking if embedding is currently performed

# When embedding_enabled is true and embedding_paused is false,
# the combined switch will return true
combined_switch.value # => true

Instance Method Summary collapse

Methods included from CheckSwitch

#off?, #show

Constructor Details

#initialize(value:, msg:) ⇒ CombinedSwitch

The initialize method sets up the switch with a value and message.

Parameters:

  • value (Object)

    the value to be stored

  • msg (Hash)

    the message hash containing true and false keys



121
122
123
124
# File 'lib/ollama_chat/switches.rb', line 121

def initialize(value:, msg:)
  @value = value
  @msg   = msg
end

Instance Method Details

#valueObject

The value method returns the result of calling the stored proc with no arguments.



128
129
130
# File 'lib/ollama_chat/switches.rb', line 128

def value
  @value.()
end