Class: OpenObserve::Record
- Inherits:
-
Object
- Object
- OpenObserve::Record
- Defined in:
- lib/openobserve/record.rb
Overview
Direct Known Subclasses
Alert, Dashboard, Destination, Hit, Incident, SearchResult, Stream, Template
Instance Attribute Summary collapse
-
#raw ⇒ Hash
readonly
The payload.
Class Method Summary collapse
-
.from(hash) ⇒ OpenObserve::Record
Build from a raw parsed response hash.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Two records are equal when they are the same class and wrap the same payload.
-
#[](key) ⇒ Object
Read any field by its OpenObserve key.
-
#hash ⇒ Integer
A hash consistent with #==, so records key Hashes / Sets correctly.
-
#id ⇒ String, ...
The object id.
-
#initialize(raw) ⇒ Record
constructor
A new instance of Record.
-
#to_h ⇒ Hash
The payload.
Constructor Details
#initialize(raw) ⇒ Record
Returns a new instance of Record.
19 20 21 |
# File 'lib/openobserve/record.rb', line 19 def initialize(raw) @raw = raw || {} end |
Instance Attribute Details
#raw ⇒ Hash (readonly)
Returns the payload.
10 11 12 |
# File 'lib/openobserve/record.rb', line 10 def raw @raw end |
Class Method Details
.from(hash) ⇒ OpenObserve::Record
Build from a raw parsed response hash.
15 16 17 |
# File 'lib/openobserve/record.rb', line 15 def self.from(hash) new(hash) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Two records are equal when they are the same class and wrap the same payload.
37 38 39 |
# File 'lib/openobserve/record.rb', line 37 def ==(other) other.instance_of?(self.class) && raw == other.raw end |
#[](key) ⇒ Object
Read any field by its OpenObserve key.
25 26 27 |
# File 'lib/openobserve/record.rb', line 25 def [](key) raw[key.to_s] end |
#hash ⇒ Integer
Returns a hash consistent with #==, so records key Hashes / Sets correctly.
43 44 45 |
# File 'lib/openobserve/record.rb', line 43 def hash [self.class, raw].hash end |
#id ⇒ String, ...
Returns the object id.
30 31 32 |
# File 'lib/openobserve/record.rb', line 30 def id self['id'] end |
#to_h ⇒ Hash
Returns the payload.
48 49 50 |
# File 'lib/openobserve/record.rb', line 48 def to_h raw end |