Module: GaEvents::List

Extended by:
Forwardable
Defined in:
lib/ga_events/list.rb

Class Method Summary collapse

Class Method Details

.init(str = nil) ⇒ Object

Init list, optionally with a string of serialized events



20
21
22
23
24
25
26
27
28
# File 'lib/ga_events/list.rb', line 20

def init(str = nil)
  Thread.current[:ga_events] = []
  if str.present?
    raw_events = JSON.parse(str)
    raw_events.each { |raw_event| GaEvents::Event.from_hash(raw_event) }
  end
rescue JSON::ParserError
  nil
end

.to_sObject



15
16
17
# File 'lib/ga_events/list.rb', line 15

def to_s
  "[#{data.collect(&:to_s).join(',')}]"
end