Class: Arango::Transaction
- Inherits:
-
Object
- Object
- Arango::Transaction
- Includes:
- Helper::DatabaseAssignment, Helper::Satisfaction
- Defined in:
- lib/arango/transaction.rb
Overview
Arango Transaction
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#database ⇒ Object
readonly
DEFINE ===.
-
#intermediate_commit_count ⇒ Object
Returns the value of attribute intermediate_commit_count.
-
#intermediate_commit_size ⇒ Object
Returns the value of attribute intermediate_commit_size.
-
#lock_timeout ⇒ Object
Returns the value of attribute lock_timeout.
-
#max_transaction_size ⇒ Object
Returns the value of attribute max_transaction_size.
-
#params ⇒ Object
Returns the value of attribute params.
-
#read ⇒ Object
DEFINE ===.
-
#result ⇒ Object
readonly
DEFINE ===.
-
#server ⇒ Object
readonly
DEFINE ===.
-
#wait_for_sync ⇒ Object
Returns the value of attribute wait_for_sync.
-
#write ⇒ Object
DEFINE ===.
Instance Method Summary collapse
- #add_read(read) ⇒ Object
- #add_write(write) ⇒ Object
-
#execute(action: @action, params: @params, max_transaction_size: @max_transaction_size, lock_timeout: @lock_timeout, wait_for_sync: @wait_for_sync, intermediate_commit_count: @intermediate_commit_count, intermediate_commit_size: @intermediate_commit_size) ⇒ Object
EXECUTE ===.
-
#initialize(action:, database:, intermediate_commit_size: nil, intermediate_commit_count: nil, lock_timeout: nil, max_transaction_size: nil, params: nil, read: [], wait_for_sync: nil, write: []) ⇒ Transaction
constructor
A new instance of Transaction.
-
#to_h ⇒ Object
TO HASH ===.
Methods included from Helper::Satisfaction
#satisfy_category?, #satisfy_class?, #satisfy_class_or_string?, #satisfy_module?, #satisfy_module_or_nil?, #satisfy_module_or_string?, #warning_deprecated
Constructor Details
#initialize(action:, database:, intermediate_commit_size: nil, intermediate_commit_count: nil, lock_timeout: nil, max_transaction_size: nil, params: nil, read: [], wait_for_sync: nil, write: []) ⇒ Transaction
Returns a new instance of Transaction.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/arango/transaction.rb', line 10 def initialize(action:, database:, intermediate_commit_size: nil, intermediate_commit_count: nil, lock_timeout: nil, max_transaction_size: nil, params: nil, read: [], wait_for_sync: nil, write: []) assign_database(database) @action = action @intermediate_commit_count = intermediate_commit_count @intermediate_commit_size = intermediate_commit_size @lock_timeout = lock_timeout @max_transaction_size = max_transaction_size @params = params @read = return_write_or_read(read) @result = nil @wait_for_sync = wait_for_sync @write = return_write_or_read(write) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def action @action end |
#database ⇒ Object (readonly)
DEFINE ===
27 28 29 |
# File 'lib/arango/transaction.rb', line 27 def database @database end |
#intermediate_commit_count ⇒ Object
Returns the value of attribute intermediate_commit_count.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def intermediate_commit_count @intermediate_commit_count end |
#intermediate_commit_size ⇒ Object
Returns the value of attribute intermediate_commit_size.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def intermediate_commit_size @intermediate_commit_size end |
#lock_timeout ⇒ Object
Returns the value of attribute lock_timeout.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def lock_timeout @lock_timeout end |
#max_transaction_size ⇒ Object
Returns the value of attribute max_transaction_size.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def max_transaction_size @max_transaction_size end |
#params ⇒ Object
Returns the value of attribute params.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def params @params end |
#read ⇒ Object
DEFINE ===
27 28 29 |
# File 'lib/arango/transaction.rb', line 27 def read @read end |
#result ⇒ Object (readonly)
DEFINE ===
27 28 29 |
# File 'lib/arango/transaction.rb', line 27 def result @result end |
#server ⇒ Object (readonly)
DEFINE ===
27 28 29 |
# File 'lib/arango/transaction.rb', line 27 def server @server end |
#wait_for_sync ⇒ Object
Returns the value of attribute wait_for_sync.
28 29 30 |
# File 'lib/arango/transaction.rb', line 28 def wait_for_sync @wait_for_sync end |
#write ⇒ Object
DEFINE ===
27 28 29 |
# File 'lib/arango/transaction.rb', line 27 def write @write end |
Instance Method Details
#add_read(read) ⇒ Object
44 45 46 47 48 |
# File 'lib/arango/transaction.rb', line 44 def add_read(read) read = return_write_or_read(read) @read ||= [] @read << read end |
#add_write(write) ⇒ Object
34 35 36 37 38 |
# File 'lib/arango/transaction.rb', line 34 def add_write(write) write = return_write_or_read(write) @write ||= [] @write << write end |
#execute(action: @action, params: @params, max_transaction_size: @max_transaction_size, lock_timeout: @lock_timeout, wait_for_sync: @wait_for_sync, intermediate_commit_count: @intermediate_commit_count, intermediate_commit_size: @intermediate_commit_size) ⇒ Object
EXECUTE ===
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/arango/transaction.rb', line 88 def execute(action: @action, params: @params, max_transaction_size: @max_transaction_size, lock_timeout: @lock_timeout, wait_for_sync: @wait_for_sync, intermediate_commit_count: @intermediate_commit_count, intermediate_commit_size: @intermediate_commit_size) body = { collections: { read: @read.map{|x| x.name}, write: @write.map{|x| x.name} }, action: action, intermediate_commit_size: intermediate_commit_size, intermediateCommitCount: intermediate_commit_count, lockTimeout: lock_timeout, maxTransactionSize: max_transaction_size, params: params, waitForSync: wait_for_sync } result = @database.request("POST", "_api/transaction", body: body) return result if @server.async != false @result = result[:result] return return_directly?(result) ? result : result[:result] end |
#to_h ⇒ Object
TO HASH ===
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/arango/transaction.rb', line 75 def to_h { action: @action, database: @database.name, params: @params, read: @read.map{|x| x.name}, result: @result, write: @write.map{|x| x.name} }.delete_if{|k,v| v.nil?} end |