Class: PrePlaySports::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/pre_play_sports/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_type, data, context) ⇒ Event

Returns a new instance of Event.



6
7
8
9
10
# File 'lib/pre_play_sports/event.rb', line 6

def initialize(event_type, data, context)
  @event_type = event_type
  @data = filter(data)
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



4
5
6
# File 'lib/pre_play_sports/event.rb', line 4

def context
  @context
end

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/pre_play_sports/event.rb', line 4

def data
  @data
end

#event_typeObject

Returns the value of attribute event_type.



4
5
6
# File 'lib/pre_play_sports/event.rb', line 4

def event_type
  @event_type
end

Instance Method Details

#to_scrolls_hashObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pre_play_sports/event.rb', line 12

def to_scrolls_hash
  event = {
    d: { type: event_type }.merge!(data),
    c: context,
    m: {
      dyno: $dyno_name,
      created_at: Time.now.to_s
    }
  }
  flatten_keys(event).merge!(preplay_event: true)
end