Class: Dscf::Banking::WithdrawalService
- Inherits:
-
BaseTransactionService
- Object
- BaseTransactionService
- Dscf::Banking::WithdrawalService
- Defined in:
- app/services/dscf/banking/withdrawal_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(account:, amount:, description:, transaction_type_code: "WITHDRAWAL") ⇒ WithdrawalService
constructor
A new instance of WithdrawalService.
Methods inherited from BaseTransactionService
Constructor Details
#initialize(account:, amount:, description:, transaction_type_code: "WITHDRAWAL") ⇒ WithdrawalService
Returns a new instance of WithdrawalService.
5 6 7 8 9 10 11 12 |
# File 'app/services/dscf/banking/withdrawal_service.rb', line 5 def initialize(account:, amount:, description:, transaction_type_code: "WITHDRAWAL") super() @account = 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/withdrawal_service.rb', line 3 def transaction @transaction end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/dscf/banking/withdrawal_service.rb', line 14 def execute return self unless validate_withdrawal ActiveRecord::Base.transaction do create_withdrawal_transaction return self unless success? process_withdrawal return self unless success? end self end |