Class: AgUiProtocol::Core::Events::CustomEvent

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

Overview

Used for application-specific custom events.

“‘ruby event = AgUiProtocol::Core::Events::CustomEvent.new(name: “my_event”, value: { “a” => 1 }) “`

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(name:, value:, timestamp: nil, raw_event: nil) ⇒ CustomEvent

Returns a new instance of CustomEvent.



844
845
846
847
848
# File 'lib/ag_ui_protocol/core/events.rb', line 844

def initialize(name:, value:, timestamp: nil, raw_event: nil)
  super(type: EventType::CUSTOM, timestamp: timestamp, raw_event: raw_event)
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



834
835
836
# File 'lib/ag_ui_protocol/core/events.rb', line 834

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



837
838
839
# File 'lib/ag_ui_protocol/core/events.rb', line 837

def value
  @value
end

Instance Method Details

#to_hObject



851
852
853
854
# File 'lib/ag_ui_protocol/core/events.rb', line 851

def to_h
  # `value` is an application-specific payload — preserve keys verbatim.
  super.merge(name: @name, value: @value.nil? ? nil : AgUiProtocol::Util::Opaque.new(@value))
end