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
- #count ⇒ Object
-
#initialize(wallets, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets
constructor
A new instance of SyncWallets.
- #path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(wallets, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets
Returns a new instance of SyncWallets.
36 37 38 39 40 |
# File 'lib/zold/sync_wallets.rb', line 36 def initialize(wallets, log: Log::NULL, dir: wallets.path) @wallets = wallets @log = log @dir = dir end |
Instance Method Details
#acq(id, exclusive: false) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/zold/sync_wallets.rb', line 58 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
50 51 52 |
# File 'lib/zold/sync_wallets.rb', line 50 def all @wallets.all end |
#count ⇒ Object
54 55 56 |
# File 'lib/zold/sync_wallets.rb', line 54 def count @wallets.count end |
#path ⇒ Object
46 47 48 |
# File 'lib/zold/sync_wallets.rb', line 46 def path @wallets.path end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/zold/sync_wallets.rb', line 42 def to_s @wallets.to_s end |