Class: Minuteman::User

Inherits:
Ohm::Model
  • Object
show all
Defined in:
lib/minuteman/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](identifier_or_uuid) ⇒ Object



43
44
45
# File 'lib/minuteman/user.rb', line 43

def self.[](identifier_or_uuid)
  with(:uid, identifier_or_uuid) || with(:identifier, identifier_or_uuid)
end

Instance Method Details

#add(action, time = Time.now.utc) ⇒ Object



25
26
27
# File 'lib/minuteman/user.rb', line 25

def add(action, time = Time.now.utc)
  Minuteman.add(action, time, self)
end

#anonymous?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/minuteman/user.rb', line 33

def anonymous?
  self.anonymous == true
end

#count(action, time = Time.now.utc) ⇒ Object



29
30
31
# File 'lib/minuteman/user.rb', line 29

def count(action, time = Time.now.utc)
  Minuteman::Analyzer.new(action, Minuteman::Counter::User, self)
end

#promote(identifier) ⇒ Object



37
38
39
40
41
# File 'lib/minuteman/user.rb', line 37

def promote(identifier)
  self.identifier = identifier
  self.anonymous = false
  save
end

#saveObject



15
16
17
18
19
# File 'lib/minuteman/user.rb', line 15

def save
  self.uid ||= SecureRandom.uuid
  self.anonymous ||= !identifier
  super
end

#track(action, time = Time.now.utc) ⇒ Object



21
22
23
# File 'lib/minuteman/user.rb', line 21

def track(action, time = Time.now.utc)
  Minuteman.track(action, self, time)
end