Class: Metry::Visitor

Inherits:
Object
  • Object
show all
Includes:
MongoMapper::Document
Defined in:
lib/metry/visitor.rb

Instance Method Summary collapse

Instance Method Details

#cohortsObject



26
27
28
# File 'lib/metry/visitor.rb', line 26

def cohorts
  [(cohort_ids.empty? ? nil : Cohort.find(cohort_ids))].flatten
end

#in_cohort(cohort) ⇒ Object



19
20
21
22
23
24
# File 'lib/metry/visitor.rb', line 19

def in_cohort(cohort)
  cohort_ids << cohort.id
  cohort.visitor_ids << self.id
  save
  cohort.save
end

#last_ipObject



11
12
13
# File 'lib/metry/visitor.rb', line 11

def last_ip
  (events.last ? events.last.ip : nil)
end

#user_agentObject



15
16
17
# File 'lib/metry/visitor.rb', line 15

def user_agent
  (events.last ? events.last.user_agent : nil)
end