Class: Zold::JournaledPipeline::Wallets
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Zold::JournaledPipeline::Wallets
- Defined in:
- lib/zold/node/journaled_pipeline.rb
Overview
Decorated wallets
Instance Method Summary collapse
- #acq(id, exclusive: false) ⇒ Object
-
#initialize(wallets, log) ⇒ Wallets
constructor
A new instance of Wallets.
Constructor Details
#initialize(wallets, log) ⇒ Wallets
Returns a new instance of Wallets.
39 40 41 42 43 |
# File 'lib/zold/node/journaled_pipeline.rb', line 39 def initialize(wallets, log) @wallets = wallets @log = log super(wallets) end |
Instance Method Details
#acq(id, exclusive: false) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/zold/node/journaled_pipeline.rb', line 45 def acq(id, exclusive: false) @wallets.acq(id, exclusive: exclusive) do |wallet| return yield wallet unless exclusive before = wallet.exists? ? File.read(wallet.path) : '' res = yield wallet after = wallet.exists? ? File.read(wallet.path) : '' unless before == after diff = Diffy::Diff.new(before, after, context: 0).to_s @log.info("The wallet #{id} was modified:\n #{diff.gsub("\n", "\n ")}") end res end end |