Class: Ahoy::Subscribers::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ahoy/subscribers/active_record.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



4
5
6
# File 'lib/ahoy/subscribers/active_record.rb', line 4

def initialize(options = {})
  @model = options[:model] || Ahoy::Event
end

Instance Method Details

#track(name, properties, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/ahoy/subscribers/active_record.rb', line 8

def track(name, properties, options = {})
  @model.create! do |e|
    e.visit = options[:visit]
    e.user = options[:user]
    e.name = name
    e.properties = properties
    e.time = options[:time]
  end
end