Class: Arango::Transaction
- Inherits:
-
Object
- Object
- Arango::Transaction
- Includes:
- Database_Return, Helper_Error, Helper_Return
- Defined in:
- lib/Transaction.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#database ⇒ Object
readonly
DEFINE ===.
-
#intermedateCommitSize ⇒ Object
Returns the value of attribute intermedateCommitSize.
-
#intermediateCommitCount ⇒ Object
Returns the value of attribute intermediateCommitCount.
-
#lockTimeout ⇒ Object
Returns the value of attribute lockTimeout.
-
#maxTransactionSize ⇒ Object
Returns the value of attribute maxTransactionSize.
-
#params ⇒ Object
Returns the value of attribute params.
-
#read ⇒ Object
DEFINE ===.
-
#result ⇒ Object
readonly
DEFINE ===.
-
#server ⇒ Object
readonly
DEFINE ===.
-
#waitForSync ⇒ Object
Returns the value of attribute waitForSync.
-
#write ⇒ Object
DEFINE ===.
Instance Method Summary collapse
- #addRead(read) ⇒ Object
- #addWrite(write) ⇒ Object
-
#execute(action: @action, params: @params, maxTransactionSize: @maxTransactionSize, lockTimeout: @lockTimeout, waitForSync: @waitForSync, intermediateCommitCount: @intermediateCommitCount, intermedateCommitSize: @intermedateCommitSize) ⇒ Object
EXECUTE ===.
-
#initialize(database:, action:, write: [], read: [], params: nil, maxTransactionSize: nil, lockTimeout: nil, waitForSync: nil, intermediateCommitCount: nil, intermedateCommitSize: nil) ⇒ Transaction
constructor
A new instance of Transaction.
-
#to_h ⇒ Object
TO HASH ===.
Methods included from Database_Return
Methods included from Helper_Return
#return_delete, #return_directly?, #return_element
Methods included from Helper_Error
#satisfy_category?, #satisfy_class?, #warning_deprecated
Constructor Details
#initialize(database:, action:, write: [], read: [], params: nil, maxTransactionSize: nil, lockTimeout: nil, waitForSync: nil, intermediateCommitCount: nil, intermedateCommitSize: nil) ⇒ Transaction
Returns a new instance of Transaction.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/Transaction.rb', line 9 def initialize(database:, action:, write: [], read: [], params: nil, maxTransactionSize: nil, lockTimeout: nil, waitForSync: nil, intermediateCommitCount: nil, intermedateCommitSize: nil) assign_database(database) @action = action @write = return_write_or_read(write) @read = return_write_or_read(read) @params = params @maxTransactionSize = maxTransactionSize @lockTimeout = lockTimeout @waitForSync = waitForSync @intermediateCommitCount = intermediateCommitCount @intermedateCommitSize = intermedateCommitSize @result = nil end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def action @action end |
#database ⇒ Object (readonly)
DEFINE ===
26 27 28 |
# File 'lib/Transaction.rb', line 26 def database @database end |
#intermedateCommitSize ⇒ Object
Returns the value of attribute intermedateCommitSize.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def intermedateCommitSize @intermedateCommitSize end |
#intermediateCommitCount ⇒ Object
Returns the value of attribute intermediateCommitCount.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def intermediateCommitCount @intermediateCommitCount end |
#lockTimeout ⇒ Object
Returns the value of attribute lockTimeout.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def lockTimeout @lockTimeout end |
#maxTransactionSize ⇒ Object
Returns the value of attribute maxTransactionSize.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def maxTransactionSize @maxTransactionSize end |
#params ⇒ Object
Returns the value of attribute params.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def params @params end |
#read ⇒ Object
DEFINE ===
26 27 28 |
# File 'lib/Transaction.rb', line 26 def read @read end |
#result ⇒ Object (readonly)
DEFINE ===
26 27 28 |
# File 'lib/Transaction.rb', line 26 def result @result end |
#server ⇒ Object (readonly)
DEFINE ===
26 27 28 |
# File 'lib/Transaction.rb', line 26 def server @server end |
#waitForSync ⇒ Object
Returns the value of attribute waitForSync.
27 28 29 |
# File 'lib/Transaction.rb', line 27 def waitForSync @waitForSync end |
#write ⇒ Object
DEFINE ===
26 27 28 |
# File 'lib/Transaction.rb', line 26 def write @write end |
Instance Method Details
#addRead(read) ⇒ Object
45 46 47 48 49 |
# File 'lib/Transaction.rb', line 45 def addRead(read) read = return_write_or_read(read) @read ||= [] @read << read end |
#addWrite(write) ⇒ Object
35 36 37 38 39 |
# File 'lib/Transaction.rb', line 35 def addWrite(write) write = return_write_or_read(write) @write ||= [] @write << write end |
#execute(action: @action, params: @params, maxTransactionSize: @maxTransactionSize, lockTimeout: @lockTimeout, waitForSync: @waitForSync, intermediateCommitCount: @intermediateCommitCount, intermedateCommitSize: @intermedateCommitSize) ⇒ Object
EXECUTE ===
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/Transaction.rb', line 91 def execute(action: @action, params: @params, maxTransactionSize: @maxTransactionSize, lockTimeout: @lockTimeout, waitForSync: @waitForSync, intermediateCommitCount: @intermediateCommitCount, intermedateCommitSize: @intermedateCommitSize) body = { "collections": { "read": @read.map{|x| x.name}, "write": @write.map{|x| x.name} }, "action": action, "params": params, "lockTimeout": lockTimeout, "waitForSync": waitForSync, "maxTransactionSize": maxTransactionSize, "intermediateCommitCount": intermediateCommitCount, "intermedateCommitSize": intermedateCommitSize } 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 ===
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/Transaction.rb', line 78 def to_h { "action": @action, "result": @result, "params": @params, "read": @read.map{|x| x.name}, "write": @write.map{|x| x.name}, "database": @database.name }.delete_if{|k,v| v.nil?} end |