class Deb::Builder
Attributes
credits[R]
debits[R]
description[R]
reference[R]
Public Class Methods
new()
click to toggle source
# File lib/deb/builder.rb, line 29 def initialize @debits ||= {} @credits ||= {} end
Public Instance Methods
build()
click to toggle source
# File lib/deb/builder.rb, line 34 def build Deb::Entry.new(description: @description, transactionable: @reference, kind: @kind) do |t| credits.each do |account, amount| t.credit_items.build(account: account, amount: amount) end debits.each do |account, amount| t.debit_items.build(account: account, amount: amount) end end end
credit(account, amount)
click to toggle source
# File lib/deb/builder.rb, line 11 def credit(account, amount) @credits ||= {} @credits[account] ||= 0 @credits[account] += amount end
debit(account, amount)
click to toggle source
# File lib/deb/builder.rb, line 5 def debit(account, amount) @debits ||= {} @debits[account] ||= 0 @debits[account] += amount end
kind(kind)
click to toggle source
# File lib/deb/builder.rb, line 21 def kind(kind) @kind = kind end