Class: Ahoy::Stores::BunnyStore

Inherits:
LogStore show all
Defined in:
lib/ahoy/stores/bunny_store.rb

Instance Method Summary collapse

Methods inherited from LogStore

#track_event, #track_visit

Methods inherited from BaseStore

#authenticate, #exclude?, #generate_id, #initialize, #report_exception, #track_event, #track_visit, #user, #visit

Constructor Details

This class inherits a constructor from Ahoy::Stores::BaseStore

Instance Method Details

#channelObject



12
13
14
15
16
17
18
# File 'lib/ahoy/stores/bunny_store.rb', line 12

def channel
  @channel ||= begin
    conn = Bunny.new
    conn.start
    conn.create_channel
  end
end

#events_queueObject



28
29
30
# File 'lib/ahoy/stores/bunny_store.rb', line 28

def events_queue
  "ahoy_events"
end

#log_event(data) ⇒ Object



8
9
10
# File 'lib/ahoy/stores/bunny_store.rb', line 8

def log_event(data)
  post(events_queue, data)
end

#log_visit(data) ⇒ Object



4
5
6
# File 'lib/ahoy/stores/bunny_store.rb', line 4

def log_visit(data)
  post(visits_queue, data)
end

#post(queue, message) ⇒ Object



20
21
22
# File 'lib/ahoy/stores/bunny_store.rb', line 20

def post(queue, message)
  channel.queue(queue, durable: true).publish(message.to_json)
end

#visits_queueObject



24
25
26
# File 'lib/ahoy/stores/bunny_store.rb', line 24

def visits_queue
  "ahoy_visits"
end