Module: EffectiveAfterCommit::Base

Defined in:
app/models/concerns/effective_after_commit.rb

Instance Method Summary collapse

Instance Method Details

#after_commit(connection: self.class.connection, &callback) ⇒ Object



13
14
15
# File 'app/models/concerns/effective_after_commit.rb', line 13

def after_commit(connection: self.class.connection, &callback)
  Effective::AfterCommit.register_callback(connection: connection, name: __method__, callback: callback, no_tx_action: :execute)
end

#after_rollback(connection: self.class.connection, &callback) ⇒ Object



23
24
25
26
# File 'app/models/concerns/effective_after_commit.rb', line 23

def after_rollback(connection: self.class.connection, &callback)
  raise('expected a block') unless block_given?
  Effective::AfterCommit.register_callback(connection: connection, name: __method__, callback: callback, no_tx_action: :exception)
end

#before_commit(connection: self.class.connection, &callback) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
20
21
# File 'app/models/concerns/effective_after_commit.rb', line 17

def before_commit(connection: self.class.connection, &callback)
  raise(NotImplementedError, "#{__method__} works only with Rails 5.0+") if ActiveRecord::VERSION::MAJOR < 5

  Effective::AfterCommit.register_callback(connection: connection, name: __method__, callback: callback, no_tx_action: :warn_and_execute)
end