class Zold::JournaledPipeline::Wallets

Decorated wallets

Public Class Methods

new(wallets, log) click to toggle source
Calls superclass method
# File lib/zold/node/journaled_pipeline.rb, line 39
def initialize(wallets, log)
  @wallets = wallets
  @log = log
  super(wallets)
end

Public Instance Methods

acq(id, exclusive: false) { |wallet| ... } click to toggle source
# 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? ? IO.read(wallet.path) : ''
    res = yield wallet
    after = wallet.exists? ? IO.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