Module: OllamaChat::Switches::PerformCallbacks
- Included in:
- DatabaseSwitch, Switch
- Defined in:
- lib/ollama_chat/switches.rb
Overview
A module that intercepts switch state changes to execute registered callbacks.
This module is designed to be prepended into switch classes. It captures the value before and after a change occurs, then triggers any proc associated with that specific transition in the ‘@callbacks` hash.
Instance Method Summary collapse
-
#set(*a, **kw) ⇒ Object
Intercepts the set operation to trigger state-transition callbacks.
-
#toggle(**kw) ⇒ Object
Intercepts the toggle operation to trigger state-transition callbacks.
Instance Method Details
#set(*a, **kw) ⇒ Object
Intercepts the set operation to trigger state-transition callbacks.
59 60 61 62 63 64 |
# File 'lib/ollama_chat/switches.rb', line 59 def set(*a, **kw) before_value = value result = super perform_callbacks(before_value) result end |
#toggle(**kw) ⇒ Object
Intercepts the toggle operation to trigger state-transition callbacks.
70 71 72 73 74 75 |
# File 'lib/ollama_chat/switches.rb', line 70 def toggle(**kw) before_value = value result = super perform_callbacks(before_value) result end |