Class: StatisticCounter

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/statistic_counter.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ StatisticCounter

Returns a new instance of StatisticCounter.



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

def initialize(options = {})
  super(options = {})
  set_default_date_to_current
end

Instance Method Details

#increment_counterObject



9
10
11
12
13
14
15
16
# File 'app/models/statistic_counter.rb', line 9

def increment_counter
   sc = self.class.find_by_element_id_and_date_and_element_type( element_id, date, element_type )
   if sc
     sc.increment!(:counter)
   else
     save
   end
end