Class: HermesAgent::Client::Entity
- Inherits:
-
Object
- Object
- HermesAgent::Client::Entity
- Defined in:
- lib/hermes_agent/client/entity.rb
Overview
Base class for lightweight wrappers around parsed JSON payloads.
Subclasses add method readers for the fields we have mapped, but the raw parsed payload is always available as the source of truth: #to_h returns the full hash and #[] reads an individual key.
Entities are immutable value objects: both the entity and its underlying payload are frozen on construction, and equality (#== / #eql? / #hash) is by class and payload, so entities can be compared and used as Hash keys.
Direct Known Subclasses
HermesAgent::Client::Entities::Auth, HermesAgent::Client::Entities::Capabilities, HermesAgent::Client::Entities::ChatChoice, HermesAgent::Client::Entities::ChatCompletion, HermesAgent::Client::Entities::ChatCompletionChunk, HermesAgent::Client::Entities::ChatMessage, HermesAgent::Client::Entities::ChatToolProgress, HermesAgent::Client::Entities::ChatUsage, HermesAgent::Client::Entities::Endpoint, HermesAgent::Client::Entities::Features, HermesAgent::Client::Entities::Health, HermesAgent::Client::Entities::HealthDetails, HermesAgent::Client::Entities::Job, HermesAgent::Client::Entities::JobRepeat, HermesAgent::Client::Entities::JobSchedule, HermesAgent::Client::Entities::Model, HermesAgent::Client::Entities::PlatformStatus, HermesAgent::Client::Entities::Response, HermesAgent::Client::Entities::ResponseContent, HermesAgent::Client::Entities::ResponseDeletion, HermesAgent::Client::Entities::ResponseOutputItem, HermesAgent::Client::Entities::ResponseStreamEvent, HermesAgent::Client::Entities::ResponseUsage, HermesAgent::Client::Entities::Run, HermesAgent::Client::Entities::RunApprovalResponse, HermesAgent::Client::Entities::RunEvent, HermesAgent::Client::Entities::RunStop, HermesAgent::Client::Entities::RunUsage, HermesAgent::Client::Entities::Runtime
Instance Method Summary collapse
-
#==(other) ⇒ boolean
Whether this entity equals another: true when
otheris an instance of the same class wrapping equal payload data. -
#[](key) ⇒ Object?
Read a raw field by its server-side (string) key.
- #eql?(other) ⇒ boolean
- #hash ⇒ Integer
-
#to_h ⇒ Hash
The full parsed payload (frozen).
Instance Method Details
#==(other) ⇒ boolean
Whether this entity equals another: true when other is an instance of
the same class wrapping equal payload data.
64 65 66 |
# File 'lib/hermes_agent/client/entity.rb', line 64 def ==(other) other.instance_of?(self.class) && other.to_h == @data end |
#[](key) ⇒ Object?
Read a raw field by its server-side (string) key.
44 45 46 |
# File 'lib/hermes_agent/client/entity.rb', line 44 def [](key) @data[key] end |
#eql?(other) ⇒ boolean
75 76 77 |
# File 'lib/hermes_agent/client/entity.rb', line 75 def eql?(other) self == other end |
#hash ⇒ Integer
84 85 86 |
# File 'lib/hermes_agent/client/entity.rb', line 84 def hash [self.class, @data].hash end |
#to_h ⇒ Hash
The full parsed payload (frozen).
53 54 55 |
# File 'lib/hermes_agent/client/entity.rb', line 53 def to_h @data end |