Class: CachedCounter::RollbackByMethodCallListener
- Inherits:
-
Object
- Object
- CachedCounter::RollbackByMethodCallListener
- Defined in:
- lib/cached_counter.rb
Instance Method Summary collapse
- #committed! ⇒ Object
-
#has_transactional_callbacks? ⇒ Boolean
called only when Rails is 4+ Without this method implemented, you will see ‘undefined method `has_transactional_callbacks?’ for #<CachedCounter::RollbackByMethodCallListener:0x007f5af749cd80>‘ when the listener is passed to
#add_transaction_record. -
#initialize(model_class:, id:, attribute:, method:) ⇒ RollbackByMethodCallListener
constructor
A new instance of RollbackByMethodCallListener.
- #rolledback!(force_restore_state = false) ⇒ Object
Constructor Details
#initialize(model_class:, id:, attribute:, method:) ⇒ RollbackByMethodCallListener
Returns a new instance of RollbackByMethodCallListener.
231 232 233 234 235 236 |
# File 'lib/cached_counter.rb', line 231 def initialize(model_class:, id:, attribute:, method:) @model_class = model_class @id = id @attribute = attribute @method = method end |
Instance Method Details
#committed! ⇒ Object
248 249 250 |
# File 'lib/cached_counter.rb', line 248 def committed! nil end |
#has_transactional_callbacks? ⇒ Boolean
called only when Rails is 4+ Without this method implemented, you will see ‘undefined method `has_transactional_callbacks?’ for #<CachedCounter::RollbackByMethodCallListener:0x007f5af749cd80>‘ when the listener is passed to #add_transaction_record
242 243 244 |
# File 'lib/cached_counter.rb', line 242 def has_transactional_callbacks? true end |
#rolledback!(force_restore_state = false) ⇒ Object
255 256 257 |
# File 'lib/cached_counter.rb', line 255 def rolledback!(force_restore_state = false) CachedCounter.new(model_class: @model_class, id: @id, attribute: @attribute).send(@method) end |