Class: Transaction
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Transaction
- Defined in:
- app/models/transaction.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#account_from ⇒ Object
Returns the value of attribute account_from.
-
#account_to ⇒ Object
Returns the value of attribute account_to.
-
#amount ⇒ Object
Returns the value of attribute amount.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#account_from ⇒ Object
Returns the value of attribute account_from.
11 12 13 |
# File 'app/models/transaction.rb', line 11 def account_from @account_from end |
#account_to ⇒ Object
Returns the value of attribute account_to.
11 12 13 |
# File 'app/models/transaction.rb', line 11 def account_to @account_to end |
#amount ⇒ Object
Returns the value of attribute amount.
11 12 13 |
# File 'app/models/transaction.rb', line 11 def amount @amount end |
Class Method Details
.belongs_to_auxilliary_model(model) ⇒ Object
13 14 15 16 |
# File 'app/models/transaction.rb', line 13 def self.belongs_to_auxilliary_model(model) klass = model.to_s.classify belongs_to klass.underscore.to_sym, :foreign_key => :auxilliary_model_id end |
.required_auxilliary_model(model) ⇒ Object
18 19 20 21 |
# File 'app/models/transaction.rb', line 18 def self.required_auxilliary_model(model) belongs_to_auxilliary_model(model) validates_presence_of model.to_s.classify.underscore.to_sym end |
Instance Method Details
#completed? ⇒ Boolean
23 24 25 |
# File 'app/models/transaction.rb', line 23 def completed? !debit.nil? and !credit.nil? end |
#readonly? ⇒ Boolean
43 44 45 |
# File 'app/models/transaction.rb', line 43 def readonly? !new_record? end |
#transaction_date ⇒ Object
39 40 41 |
# File 'app/models/transaction.rb', line 39 def transaction_date super or created_at end |