Class: Capacitor::CounterCache
- Inherits:
-
Object
- Object
- Capacitor::CounterCache
- Defined in:
- lib/capacitor/counter_cache.rb
Overview
Public: The public interface to incrementing and decrementing the counter cache
klass - ActiveRecord class id - record id column - counter column symbol
Instance Method Summary collapse
-
#decrement ⇒ Object
Public: decrement ‘column` by 1.
-
#increment ⇒ Object
Public: increment ‘column` by 1.
-
#initialize(klass, id, column) ⇒ CounterCache
constructor
A new instance of CounterCache.
Constructor Details
#initialize(klass, id, column) ⇒ CounterCache
Returns a new instance of CounterCache.
8 9 10 11 12 |
# File 'lib/capacitor/counter_cache.rb', line 8 def initialize(klass, id, column) @classname = klass.to_s @id = id.to_s @column = column end |
Instance Method Details
#decrement ⇒ Object
Public: decrement ‘column` by 1
Returns: nothing
24 25 26 |
# File 'lib/capacitor/counter_cache.rb', line 24 def decrement enqueue_count_change -1 end |
#increment ⇒ Object
Public: increment ‘column` by 1
Returns: nothing
17 18 19 |
# File 'lib/capacitor/counter_cache.rb', line 17 def increment enqueue_count_change 1 end |