Class: Rollout::Logging::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rollout/logging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature: nil, name:, data:, context: {}, created_at:) ⇒ Event

Returns a new instance of Event.



18
19
20
21
22
23
24
# File 'lib/rollout/logging.rb', line 18

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.



16
17
18
# File 'lib/rollout/logging.rb', line 16

def context
  @context
end

#created_at ⇒ Object (readonly)

Returns the value of attribute created_at.



16
17
18
# File 'lib/rollout/logging.rb', line 16

def created_at
  @created_at
end

#data ⇒ Object (readonly)

Returns the value of attribute data.



16
17
18
# File 'lib/rollout/logging.rb', line 16

def data
  @data
end

#feature ⇒ Object (readonly)

Returns the value of attribute feature.



16
17
18
# File 'lib/rollout/logging.rb', line 16

def feature
  @feature
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/rollout/logging.rb', line 16

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
43
44
45
# File 'lib/rollout/logging.rb', line 40

def ==(other)
  feature == other.feature \
    && name == other.name \
    && data == other.data \
    && created_at == other.created_at
end

#serialize ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rollout/logging.rb', line 30

def serialize
  JSON.dump(
    feature: @feature,
    name: @name,
    data: @data,
    context: @context,
    created_at: @created_at,
  )
end

#timestamp ⇒ Object



26
27
28
# File 'lib/rollout/logging.rb', line 26

def timestamp
  (@created_at.to_f * 1_000_000).to_i
end