module MudratProjector::TransactionEntry::Factory
Public Instance Methods
new(params = {})
click to toggle source
Calls superclass method
# File lib/mudrat_projector/transaction_entry.rb, line 6 def new params = {} catch :instance do maybe_build_new_fixed_entry params maybe_build_new_percentage_entry params super end end
new_credit(params = {})
click to toggle source
# File lib/mudrat_projector/transaction_entry.rb, line 14 def new_credit params = {} params = { credit_or_debit: :credit }.merge params new params end
new_debit(params = {})
click to toggle source
# File lib/mudrat_projector/transaction_entry.rb, line 19 def new_debit params = {} params = { credit_or_debit: :debit }.merge params new params end
Private Instance Methods
maybe_build_new_fixed_entry(params)
click to toggle source
# File lib/mudrat_projector/transaction_entry.rb, line 26 def maybe_build_new_fixed_entry params return unless params.has_key? :amount params = params.dup params[:scalar] = params.delete :amount throw :instance, new(params).tap(&:calculate) end
maybe_build_new_percentage_entry(params)
click to toggle source
# File lib/mudrat_projector/transaction_entry.rb, line 33 def maybe_build_new_percentage_entry params return unless params.has_key?(:percent) && self == TransactionEntry params = params.dup params[:scalar] = params.delete :percent params[:other_account_id] = params.delete :of throw :instance, PercentageTransactionEntry.new(params) end