Module: Tally
- Extended by:
- ActiveSupport::Autoload, Calculators
- Includes:
- ActiveSupport::Configurable
- Defined in:
- app/models/tally/record.rb,
lib/tally.rb,
lib/tally/daily.rb,
lib/tally/engine.rb,
lib/tally/keyable.rb,
lib/tally/sweeper.rb,
lib/tally/version.rb,
lib/tally/archiver.rb,
lib/tally/countable.rb,
lib/tally/increment.rb,
lib/tally/calculator.rb,
lib/tally/key_finder.rb,
lib/tally/calculators.rb,
lib/tally/record_searcher.rb,
lib/tally/key_finder/entry.rb,
lib/tally/calculator_runner.rb,
app/jobs/tally/application_job.rb,
app/helpers/tally/increment_helper.rb,
app/models/tally/application_record.rb,
app/helpers/tally/application_helper.rb,
app/jobs/tally/calculator_runner_job.rb,
app/controllers/tally/days_controller.rb,
app/controllers/tally/keys_controller.rb,
app/presenters/tally/record_presenter.rb,
app/controllers/tally/records_controller.rb,
app/controllers/tally/application_controller.rb
Overview
Schema Information
Table name: tally_records
id :integer not null, primary key
day :date
recordable_id :integer
recordable_type :string
key :string
value :integer default(0)
created_at :datetime not null
updated_at :datetime not null
Defined Under Namespace
Modules: ApplicationHelper, Calculator, Calculators, Countable, IncrementHelper, Keyable Classes: ApplicationController, ApplicationJob, ApplicationRecord, Archiver, CalculatorRunner, CalculatorRunnerJob, Daily, DaysController, Engine, Increment, KeyFinder, KeysController, Record, RecordPresenter, RecordSearcher, RecordsController, Sweeper
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
- .increment(*args) ⇒ Object
-
.redis(&block) ⇒ Object
If sidekiq is available, piggyback on its pooling.
- .redis_connection ⇒ Object
- .redis_connection=(connection) ⇒ Object
- .redis_pool ⇒ Object
- .redis_pool=(pool) ⇒ Object
Methods included from Calculators
calculators, register_calculator, unregister_calculator
Class Method Details
.increment(*args) ⇒ Object
88 89 90 |
# File 'lib/tally.rb', line 88 def self.increment(*args) Increment.public_send(:increment, *args) end |
.redis(&block) ⇒ Object
If sidekiq is available, piggyback on its pooling
Otherwise, just use redis directly
60 61 62 63 64 65 66 67 68 |
# File 'lib/tally.rb', line 60 def self.redis(&block) raise ArgumentError, "requires a block" unless block_given? if defined?(Sidekiq) Sidekiq.redis(&block) else redis_pool.with(&block) end end |
.redis_connection ⇒ Object
70 71 72 |
# File 'lib/tally.rb', line 70 def self.redis_connection @redis_connection ||= Redis.new(Tally.config.redis_config) end |
.redis_connection=(connection) ⇒ Object
74 75 76 |
# File 'lib/tally.rb', line 74 def self.redis_connection=(connection) @redis_connection = connection end |
.redis_pool ⇒ Object
78 79 80 81 82 |
# File 'lib/tally.rb', line 78 def self.redis_pool @redis_pool ||= ConnectionPool.new(Tally.config.redis_pool_config) do redis_connection end end |
.redis_pool=(pool) ⇒ Object
84 85 86 |
# File 'lib/tally.rb', line 84 def self.redis_pool=(pool) @redis_pool = pool end |