Class: Ashikawa::Core::Transaction
- Inherits:
-
Object
- Object
- Ashikawa::Core::Transaction
- Defined in:
- lib/ashikawa-core/transaction.rb
Overview
A JavaScript Transaction on the database
Instance Method Summary collapse
-
#execute(action_parameters = :no_params_provided) ⇒ Object
Execute the transaction.
-
#initialize(database, action, options) ⇒ Transaction
constructor
Initialize a Transaction.
-
#lock_timeout ⇒ Fixnum
An optional numeric value used to set a timeout for waiting on collection locks.
-
#lock_timeout=(timeout) ⇒ Object
An optional numeric value used to set a timeout for waiting on collection locks.
-
#read_collections ⇒ Array<String>
The collections the transaction reads from.
-
#wait_for_sync ⇒ Boolean
If set to true, the transaction will write all data to disk before returning.
-
#wait_for_sync=(wait_for_sync) ⇒ Object
If set to true, the transaction will write all data to disk before returning.
-
#write_collections ⇒ Array<String>
The collections the transaction writes to.
Constructor Details
#initialize(database, action, options) ⇒ Transaction
Initialize a Transaction
76 77 78 79 80 81 82 83 |
# File 'lib/ashikawa-core/transaction.rb', line 76 def initialize(database, action, ) @database = database @request_parameters = { action: action, collections: , waitForSync: false } end |
Instance Method Details
#execute(action_parameters = :no_params_provided) ⇒ Object
Execute the transaction
92 93 94 95 96 |
# File 'lib/ashikawa-core/transaction.rb', line 92 def execute(action_parameters = :no_params_provided) @request_parameters[:params] = action_parameters unless action_parameters == :no_params_provided response = @database.send_request('transaction', post: @request_parameters) response['result'] end |
#lock_timeout ⇒ Fixnum
An optional numeric value used to set a timeout for waiting on collection locks
52 53 54 |
# File 'lib/ashikawa-core/transaction.rb', line 52 def lock_timeout @request_parameters[:lockTimeout] end |
#lock_timeout=(timeout) ⇒ Object
An optional numeric value used to set a timeout for waiting on collection locks
62 63 64 |
# File 'lib/ashikawa-core/transaction.rb', line 62 def lock_timeout=(timeout) @request_parameters[:lockTimeout] = timeout end |
#read_collections ⇒ Array<String>
The collections the transaction reads from
22 23 24 |
# File 'lib/ashikawa-core/transaction.rb', line 22 def read_collections @request_parameters[:collections][:read] end |
#wait_for_sync ⇒ Boolean
If set to true, the transaction will write all data to disk before returning
32 33 34 |
# File 'lib/ashikawa-core/transaction.rb', line 32 def wait_for_sync @request_parameters[:waitForSync] end |
#wait_for_sync=(wait_for_sync) ⇒ Object
If set to true, the transaction will write all data to disk before returning
42 43 44 |
# File 'lib/ashikawa-core/transaction.rb', line 42 def wait_for_sync=(wait_for_sync) @request_parameters[:waitForSync] = wait_for_sync end |
#write_collections ⇒ Array<String>
The collections the transaction writes to
12 13 14 |
# File 'lib/ashikawa-core/transaction.rb', line 12 def write_collections @request_parameters[:collections][:write] end |