Module: Helene::Sdb::Base::Transaction
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#id ⇒ Object
23 24 25 |
# File 'lib/helene/sdb/base/transactions.rb', line 23 def id id? ? @id : generate_id end |
#time ⇒ Object
35 36 37 |
# File 'lib/helene/sdb/base/transactions.rb', line 35 def time time? ? @time : Time.now.utc end |
Instance Method Details
#call(*args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/helene/sdb/base/transactions.rb', line 8 def call(*args, &block) return block.call() if id? @id = generate_id @time = Time.now.utc begin block.call() ensure @id = @time = nil end end |
#generate_id ⇒ Object
27 28 29 |
# File 'lib/helene/sdb/base/transactions.rb', line 27 def generate_id UUID.().to_s end |
#id? ⇒ Boolean
19 20 21 |
# File 'lib/helene/sdb/base/transactions.rb', line 19 def id? defined?(@id) and @id end |
#time? ⇒ Boolean
31 32 33 |
# File 'lib/helene/sdb/base/transactions.rb', line 31 def time? defined?(@time) and @time end |