Examples:
require 'ass_ole'
require 'ass_ole/snippets/shred/in_transaction_do'
PLATFORM_REQUIRE = '~> 8.3.10.0'
module AccountingRuntime
is_ole_runtime :external
end
module HrmRuntime
is_ole_runtime :external
end
class AcctWorker
like_ole_runtime AccountingRuntime
include AssOle::Snipptes::Shared::InTransactionDo
attr_reader :ib
def initialize(connection_string)
@ib = AssMaintainer::InfoBase
.new('accounting', connection_string, PLATFORM_REQUIRE)
ole_runtime_get.run ib
end
def action_one
end
def action_two(action_one_result)
end
def make_job_in_transaction
in_transaction do
make_job
end
end
def make_job
action_two(action_one)
end
end
class HrmWorker
like_ole_runtime HrmRuntime
include AssOle::Snipptes::Shared::InTransactionDo
attr_reader :ib
def initialize(connection_string)
@ib = AssMaintainer::InfoBase
.new('accounting', connection_string, PLATFORM_REQUIRE)
ole_runtime_get.run ib
end
def action_one(acct_result)
end
def action_two(acct_result)
end
def make_job(acct_result)
action_one(acct_result)
action_two(acct_reult)
true
end
end
module Programm
def self.execute_in_nested_transaction(acct_cs, hrm_cs)
HrmWorker.new(hrm_cs).in_transaction do |hrm_worker|
acct_result = AcctWorker.new(acct_cs).in_transaction(false) do |acct_worker|
acct_worker.make_job
end
result = hrm_worker.make_job(acct_result)
acct_worker._commit_transaction_
result
end
end
end
puts AcctWorker.new(ARGV[0]).make_job_in_transaction
puts Programm.execute_in_nested_transaction(ARGV[0], ARGV[1])