Class: UserStats

Inherits:
ApplicationRecord show all
Defined in:
app/models/user_stats.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

aggregate_of, all_except, defaults, #delete, #destroy!, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes

Class Method Details

.exp_for(user) ⇒ Object



9
10
11
# File 'app/models/user_stats.rb', line 9

def self.exp_for(user)
  self.stats_for(user).exp
end

.stats_for(user) ⇒ Object



5
6
7
# File 'app/models/user_stats.rb', line 5

def self.stats_for(user)
  UserStats.find_or_initialize_by(user: user, organization: Organization.current)
end

Instance Method Details

#add_exp!(points) ⇒ Object



13
14
15
# File 'app/models/user_stats.rb', line 13

def add_exp!(points)
  self.exp += points
end