module Tally::Countable

An ActiveSupport::Concern mixin for Rails models that want to increment counters for a specific model record.

Public Instance Methods

increment_tally(key, by = 1) click to toggle source
# File lib/tally/countable.rb, line 10
def increment_tally(key, by = 1)
  return if new_record?

  Tally.increment(key, self, by)
end
tally_records(search_params = {}) click to toggle source
# File lib/tally/countable.rb, line 16
def tally_records(search_params = {})
  if search_params.present?
    RecordSearcher.search(search_params.merge(record: self))
  else
    Record.where(recordable: self)
  end
end