Class: AgentClientProtocol::TaggedUpdate
- Inherits:
-
Object
- Object
- AgentClientProtocol::TaggedUpdate
- Defined in:
- lib/agent_client_protocol/helpers.rb
Overview
A session update tagged with its discriminator value. Serializes to include the "sessionUpdate" key in the wire format.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(tag, model) ⇒ TaggedUpdate
constructor
A new instance of TaggedUpdate.
- #inspect ⇒ Object
- #method_missing(method) ⇒ Object
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Delegate attribute access to the underlying model.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(tag, model) ⇒ TaggedUpdate
Returns a new instance of TaggedUpdate.
145 146 147 148 |
# File 'lib/agent_client_protocol/helpers.rb', line 145 def initialize(tag, model) @tag = tag @model = model end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/agent_client_protocol/helpers.rb', line 164 def method_missing(method, ...) if @model.respond_to?(method) @model.send(method, ...) else super end end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
143 144 145 |
# File 'lib/agent_client_protocol/helpers.rb', line 143 def model @model end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
143 144 145 |
# File 'lib/agent_client_protocol/helpers.rb', line 143 def tag @tag end |
Instance Method Details
#inspect ⇒ Object
172 173 174 |
# File 'lib/agent_client_protocol/helpers.rb', line 172 def inspect "#<TaggedUpdate tag=#{@tag.inspect} #{@model.inspect}>" end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Delegate attribute access to the underlying model
160 161 162 |
# File 'lib/agent_client_protocol/helpers.rb', line 160 def respond_to_missing?(method, include_private = false) @model.respond_to?(method, include_private) || super end |
#to_h ⇒ Object
150 151 152 153 |
# File 'lib/agent_client_protocol/helpers.rb', line 150 def to_h h = @model.is_a?(Schema::BaseModel) ? @model.to_h : @model {"sessionUpdate" => @tag}.merge(h) end |
#to_json ⇒ Object
155 156 157 |
# File 'lib/agent_client_protocol/helpers.rb', line 155 def to_json(*) JSON.generate(to_h, *) end |