Sha256: 0df924118b3949a7043cdea75bda14923c8394348c9948cf0aa83bfde15b29f2
Contents?: true
Size: 861 Bytes
Versions: 1
Compression:
Stored size: 861 Bytes
Contents
# frozen_string_literal: true module Generalis class Transaction < ActiveRecord::Base module Preparation extend ActiveSupport::Concern class_methods do def preparations @preparations ||= [] end def prepare_with(&block) preparations << block end end included do define_model_callbacks :prepare end # Runs a one-time setup action for the transaction. # # @return [Boolean] 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 # @return [Boolean] def prepared? persisted? || @prepared end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
generalis-0.1.0 | lib/generalis/transaction/preparation.rb |