Class: Zold::SyncWallets
- Inherits:
-
Object
- Object
- Zold::SyncWallets
- Defined in:
- lib/zold/sync_wallets.rb
Overview
Synchronized collection of wallets
Instance Method Summary collapse
- #acq(id, exclusive: false) ⇒ Object
- #all ⇒ Object
-
#initialize(wallets, timeout: 30, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets
constructor
A new instance of SyncWallets.
- #path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(wallets, timeout: 30, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets
Returns a new instance of SyncWallets.
33 34 35 36 37 38 |
# File 'lib/zold/sync_wallets.rb', line 33 def initialize(wallets, timeout: 30, log: Log::NULL, dir: wallets.path) @wallets = wallets @log = log @timeout = timeout @dir = dir end |
Instance Method Details
#acq(id, exclusive: false) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/zold/sync_wallets.rb', line 52 def acq(id, exclusive: false) @wallets.acq(id, exclusive: exclusive) do |wallet| Futex.new(wallet.path, log: @log, lock: File.join(@dir, "#{id}.lock")).open(exclusive) do yield wallet end end end |
#all ⇒ Object
48 49 50 |
# File 'lib/zold/sync_wallets.rb', line 48 def all @wallets.all end |
#path ⇒ Object
44 45 46 |
# File 'lib/zold/sync_wallets.rb', line 44 def path @wallets.path end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/zold/sync_wallets.rb', line 40 def to_s @wallets.to_s end |