Module: Generalis::Transaction::Preparation

Extended by:
ActiveSupport::Concern
Defined in:
lib/generalis/transaction/preparation.rb

Instance Method Summary collapse

Instance Method Details

#prepareBoolean

Runs a one-time setup action for the transaction.

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generalis/transaction/preparation.rb', line 25

def prepare
  return true if prepared?

  @prepared = true

  run_callbacks(:prepare) do
    self.class.preparations.each do |preparation|
      instance_exec(&preparation)
    end
  end

  @prepared
end

#prepared?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/generalis/transaction/preparation.rb', line 40

def prepared?
  persisted? || @prepared
end