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



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

def after_commit(connection: self.class.connection, &callback)
  Effective::AfterCommit.register_callback(connection: connection, name: __method__, callback: callback)
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)
end

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

Raises:

  • (NotImplementedError)


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

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)
end