Class: AgUiProtocol::Core::Events::StateDeltaEvent

Inherits:
BaseEvent show all
Defined in:
lib/ag_ui_protocol/core/events.rb

Overview

Provides a partial update to an agent’s state using JSON Patch.

“‘ruby event = AgUiProtocol::Core::Events::StateDeltaEvent.new(delta: [{ “op” => “replace”, “path” => “/a”, “value” => 2 }]) “`

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#raw_event, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Types::Model

#as_json, #to_json

Constructor Details

#initialize(delta:, timestamp: nil, raw_event: nil) ⇒ StateDeltaEvent

Returns a new instance of StateDeltaEvent.



629
630
631
632
# File 'lib/ag_ui_protocol/core/events.rb', line 629

def initialize(delta:, timestamp: nil, raw_event: nil)
  super(type: EventType::STATE_DELTA, timestamp: timestamp, raw_event: raw_event)
  @delta = delta
end

Instance Attribute Details

#deltaObject (readonly)

Returns the value of attribute delta.



623
624
625
# File 'lib/ag_ui_protocol/core/events.rb', line 623

def delta
  @delta
end

Instance Method Details

#to_hObject



635
636
637
# File 'lib/ag_ui_protocol/core/events.rb', line 635

def to_h
  super.merge(delta: @delta)
end