Class: Transaction

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/ebutil.rb

Direct Known Subclasses

Credit, Debit

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Transaction

Returns a new instance of Transaction.



135
136
137
# File 'lib/ebutil.rb', line 135

def initialize(attributes)
  @attributes = OpenStruct.new(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



150
151
152
# File 'lib/ebutil.rb', line 150

def method_missing(method, *args)
  @attributes.send(method, *args)
end

Class Method Details

.credit(attributes) ⇒ Object



138
139
140
# File 'lib/ebutil.rb', line 138

def self.credit(attributes)
  Credit.new(attributes)
end

.debit(attributes) ⇒ Object



141
142
143
# File 'lib/ebutil.rb', line 141

def self.debit(attributes)
  Debit.new(attributes)
end

Instance Method Details

#add_to(balance) ⇒ Object



147
148
149
# File 'lib/ebutil.rb', line 147

def add_to(balance)
  balance + amount
end

#export_to_eb(relations) ⇒ Object



144
145
146
# File 'lib/ebutil.rb', line 144

def export_to_eb(relations) 
  "#{kind} #{date} #{relations.find_by_account(other_account)} #{amount}"
end