Class: RubyLLM::Chat::Subscription
- Inherits:
-
Object
- Object
- RubyLLM::Chat::Subscription
- Defined in:
- lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb
Overview
Represents an active subscription to a callback event
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(callback_list, callback, monitor:, tag: nil) ⇒ Subscription
constructor
A new instance of Subscription.
- #inspect ⇒ Object
-
#unsubscribe ⇒ Object
rubocop:disable Naming/PredicateMethod.
Constructor Details
#initialize(callback_list, callback, monitor:, tag: nil) ⇒ Subscription
Returns a new instance of Subscription.
20 21 22 23 24 25 26 |
# File 'lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb', line 20 def initialize(callback_list, callback, monitor:, tag: nil) @callback_list = callback_list @callback = callback @monitor = monitor @tag = tag @active = true end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
18 19 20 |
# File 'lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb', line 18 def tag @tag end |
Instance Method Details
#active? ⇒ Boolean
38 39 40 41 42 |
# File 'lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb', line 38 def active? @monitor.synchronize do @active && @callback_list.include?(@callback) end end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb', line 44 def inspect "#<#{self.class.name} tag=#{@tag.inspect} active=#{active?}>" end |
#unsubscribe ⇒ Object
rubocop:disable Naming/PredicateMethod
28 29 30 31 32 33 34 35 36 |
# File 'lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb', line 28 def unsubscribe # rubocop:disable Naming/PredicateMethod @monitor.synchronize do return false unless @active @callback_list.delete(@callback) @active = false end true end |