Method: Factbase::Logged#txn

Defined in:
lib/factbase/logged.rb

#txnObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/factbase/logged.rb', line 48

def txn
  start = Time.now
  id = nil
  rollback = false
  r =
    @origin.txn do |fbt|
      id = fbt.object_id
      yield Factbase::Logged.new(fbt, tube: @tube)
    rescue Factbase::Rollback => e
      rollback = true
      raise e
    end
  if rollback
    @tube.say(start, "Txn ##{id} rolled back in #{start.ago}")
  else
    @tube.say(start, "Txn ##{id} touched #{r} in #{start.ago}")
  end
  r
end