Class: Smith::Budget::LedgerPublication

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/smith/budget/ledger_publication.rb

Instance Method Summary collapse

Instance Method Details

#add(next_state, token:, amounts:) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/smith/budget/ledger_publication.rb', line 19

def add(next_state, token:, amounts:)
  publish(
    next_state,
    commit: -> { reservations[token] = amounts },
    rollback: -> { reservations.delete(token) }
  )
end

#remove(next_state, token:, amounts:) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/smith/budget/ledger_publication.rb', line 27

def remove(next_state, token:, amounts:)
  publish(
    next_state,
    commit: -> { reservations.delete(token) },
    rollback: -> { reservations[token] = amounts }
  )
end

#reservation(token) ⇒ Object



15
16
17
# File 'lib/smith/budget/ledger_publication.rb', line 15

def reservation(token)
  reservations[token]
end