Sha256: 4fd01287854b4815139663d24fd7fc2ab15e90a8da8f0bbe4a2e999e07bf6ee7
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
# == Schema Information # # Table name: counter_values # # id :integer not null, primary key # type :string indexed # name :string indexed # value :integer default(0) # parent_type :string indexed => [parent_id] # parent_id :integer indexed => [parent_type] # created_at :datetime not null # updated_at :datetime not null # class Counter::Value < ApplicationRecord def self.table_name_prefix "counter_" end belongs_to :parent, polymorphic: true, optional: true validates_numericality_of :value def self.find_counter counter counter_name = if counter.is_a?(String) || counter.is_a?(Symbol) counter.to_s elsif counter.is_a?(Class) && counter.ancestors.include?(Counter::Definition) definition = counter.instance raise "Unable to find counter #{definition.name} via Counter::Value.find_counter. Use must use #{definition.model}#find_counter}" unless definition.global? counter.instance.record_name else counter.to_s end find_or_initialize_by name: counter_name end include Counter::Definable include Counter::Hooks include Counter::Increment include Counter::Reset include Counter::Recalculatable include Counter::Verifyable include Counter::Summable include Counter::Conditional include Counter::Calculated # include Counter::Hierarchical end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
counterwise-0.1.5 | app/models/counter/value.rb |
counterwise-0.1.4 | app/models/counter/value.rb |
counterwise-0.1.3 | app/models/counter/value.rb |
counterwise-0.1.2 | app/models/counter/value.rb |