Class: Rollout::Logging::Event
- Inherits:
-
Object
- Object
- Rollout::Logging::Event
- Defined in:
- lib/rollout/logging.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(feature: nil, name:, data:, context: {}, created_at:) ⇒ Event
constructor
A new instance of Event.
- #serialize ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(feature: nil, name:, data:, context: {}, created_at:) ⇒ Event
Returns a new instance of Event.
25 26 27 28 29 30 31 |
# File 'lib/rollout/logging.rb', line 25 def initialize(feature: nil, name:, data:, context: {}, created_at:) @feature = feature @name = name @data = data @context = context @created_at = created_at end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
17 18 19 |
# File 'lib/rollout/logging.rb', line 17 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
17 18 19 |
# File 'lib/rollout/logging.rb', line 17 def created_at @created_at end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
17 18 19 |
# File 'lib/rollout/logging.rb', line 17 def data @data end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
17 18 19 |
# File 'lib/rollout/logging.rb', line 17 def feature @feature end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/rollout/logging.rb', line 17 def name @name end |
Class Method Details
.from_raw(value, score) ⇒ Object
19 20 21 22 23 |
# File 'lib/rollout/logging.rb', line 19 def self.from_raw(value, score) hash = JSON.parse(value, symbolize_names: true) new(**hash.merge(created_at: Time.at(-score.to_f / 1_000_000))) end |
Instance Method Details
#==(other) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rollout/logging.rb', line 47 def ==(other) feature == other.feature \ && name == other.name \ && data == other.data \ && created_at == other.created_at end |
#serialize ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rollout/logging.rb', line 37 def serialize JSON.dump( feature: @feature, name: @name, data: @data, context: @context, created_at: @created_at, ) end |
#timestamp ⇒ Object
33 34 35 |
# File 'lib/rollout/logging.rb', line 33 def (@created_at.to_f * 1_000_000).to_i end |