Class: Dscf::Banking::TransferService
- Inherits:
-
BaseTransactionService
- Object
- BaseTransactionService
- Dscf::Banking::TransferService
- Defined in:
- app/services/dscf/banking/transfer_service.rb
Instance Attribute Summary collapse
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
Attributes inherited from BaseTransactionService
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(debit_account:, credit_account:, amount:, description:, transaction_type_code: "TRANSFER") ⇒ TransferService
constructor
A new instance of TransferService.
Methods inherited from BaseTransactionService
Constructor Details
#initialize(debit_account:, credit_account:, amount:, description:, transaction_type_code: "TRANSFER") ⇒ TransferService
Returns a new instance of TransferService.
5 6 7 8 9 10 11 12 13 |
# File 'app/services/dscf/banking/transfer_service.rb', line 5 def initialize(debit_account:, credit_account:, amount:, description:, transaction_type_code: "TRANSFER") super() @debit_account = debit_account @credit_account = credit_account @amount = amount.to_f @description = description @transaction_type_code = transaction_type_code @transaction = nil end |
Instance Attribute Details
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
3 4 5 |
# File 'app/services/dscf/banking/transfer_service.rb', line 3 def transaction @transaction end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/dscf/banking/transfer_service.rb', line 15 def execute return self unless validate_transfer ActiveRecord::Base.transaction do create_transfer_transaction return self unless success? process_transaction(@transaction) return self unless success? end self end |