class Ookkee::Builder

Attributes

registry[RW]

Public Class Methods

build() { |instance| ... } click to toggle source
# File lib/ookkee/builder.rb, line 10
def self.build
  instance = self.new
  yield instance

  instance.build_activerecord_objects
end
new() click to toggle source
# File lib/ookkee/builder.rb, line 5
def initialize
  @registry = []
  @attributes = {}
end

Public Instance Methods

build_activerecord_objects() click to toggle source
# File lib/ookkee/builder.rb, line 39
def build_activerecord_objects
  sheet = Sheet.new(
    title: @attributes[:title],
    transaction_number: @attributes[:transaction_number],
    user: @attributes[:user]
  )
  registry.each do |element|
    entry_repo.build_from_factory(sheet, element)
  end

  sheet
end
credit(account, &block) click to toggle source
# File lib/ookkee/builder.rb, line 29
def credit(account, &block)
  builder_proxy = BuilderProxy.new({builder: self})
  builder_proxy.credit(account, &block)
end
debit(account, &block) click to toggle source
# File lib/ookkee/builder.rb, line 34
def debit(account, &block)
  builder_proxy = BuilderProxy.new({builder: self})
  builder_proxy.debit(account, &block)
end
title(value) click to toggle source
# File lib/ookkee/builder.rb, line 17
def title(value)
  @attributes[:title] = value
end
transaction_number(value) click to toggle source
# File lib/ookkee/builder.rb, line 21
def transaction_number(value)
  @attributes[:transaction_number] = value
end
user(value) click to toggle source
# File lib/ookkee/builder.rb, line 25
def user(value)
  @attributes[:user] = value
end

Private Instance Methods

entry_repo() click to toggle source
# File lib/ookkee/builder.rb, line 54
def entry_repo
  @entry_repo ||= EntryRepo.new
end