Module: RunningCount::Callbacks::ClassMethods

Defined in:
lib/running_count/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#_counter_dataObject



33
34
35
# File 'lib/running_count/callbacks.rb', line 33

def _counter_data
  @counter_data ||= {}
end

#keep_running_count(relation, opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/running_count/callbacks.rb', line 18

def keep_running_count(relation, opts = {})
  data = Counter.counter_data(self.name, self.table_name, relation, opts)
  counter_column = data[:counter_column]

  _counter_data[counter_column] = data

  Counter.add_callbacks(self, opts)
end

#reconcile_changesObject



27
28
29
30
31
# File 'lib/running_count/callbacks.rb', line 27

def reconcile_changes
  self._counter_data.each_value do |data|
    Counter.reconcile_changes(data)
  end
end