Class: MoneyTracking::Domain::ExpenseFactory

Inherits:
Struct
  • Object
show all
Defined in:
lib/money_tracking/domain/expense_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#storeObject

Returns the value of attribute store

Returns:

  • (Object)

    the current value of store



3
4
5
# File 'lib/money_tracking/domain/expense_factory.rb', line 3

def store
  @store
end

Instance Method Details

#build(raw_expense, id = nil) ⇒ Object



8
9
10
11
12
# File 'lib/money_tracking/domain/expense_factory.rb', line 8

def build(raw_expense, id = nil)
  return ExpenseNotFound.new unless raw_expense
  return build(raw_expense.merge(id: id)) if id
  Expense.new(store, raw_expense)
end

#create(raw_expense) ⇒ Object



4
5
6
# File 'lib/money_tracking/domain/expense_factory.rb', line 4

def create(raw_expense)
  build(raw_expense).create
end