Class: AgUiProtocol::Core::Events::StateDeltaEvent
- Inherits:
-
BaseEvent
- Object
- Types::Model
- BaseEvent
- AgUiProtocol::Core::Events::StateDeltaEvent
- 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
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
Attributes inherited from BaseEvent
Instance Method Summary collapse
-
#initialize(delta:, timestamp: nil, raw_event: nil) ⇒ StateDeltaEvent
constructor
A new instance of StateDeltaEvent.
- #to_h ⇒ Object
Methods inherited from Types::Model
Constructor Details
#initialize(delta:, timestamp: nil, raw_event: nil) ⇒ StateDeltaEvent
Returns a new instance of StateDeltaEvent.
652 653 654 655 |
# File 'lib/ag_ui_protocol/core/events.rb', line 652 def initialize(delta:, timestamp: nil, raw_event: nil) super(type: EventType::STATE_DELTA, timestamp: , raw_event: raw_event) @delta = delta end |
Instance Attribute Details
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
646 647 648 |
# File 'lib/ag_ui_protocol/core/events.rb', line 646 def delta @delta end |
Instance Method Details
#to_h ⇒ Object
658 659 660 661 662 663 |
# File 'lib/ag_ui_protocol/core/events.rb', line 658 def to_h # `delta` is an array of JSON Patch ops; each op's `value` may carry # arbitrary user-defined keys (RFC 6902). Preserve the array # contents verbatim on the wire. super.merge(delta: @delta.nil? ? nil : AgUiProtocol::Util::Opaque.new(@delta)) end |