Class: AchClient::Abstract::AchTransaction
- Inherits:
-
Object
- Object
- AchClient::Abstract::AchTransaction
- Defined in:
- lib/ach_client/providers/abstract/ach_transaction.rb
Overview
Generic representation of a single Ach transaction
Direct Known Subclasses
AchClient::AchWorks::AchTransaction, Fake::AchTransaction, ICheckGateway::AchTransaction, Sftp::AchTransaction
Class Method Summary collapse
-
.arguments ⇒ Array
instance attributes.
Instance Method Summary collapse
-
#credit? ⇒ Boolean
True if transaction is a credit.
-
#debit? ⇒ Boolean
True if transaction is a debit.
-
#do_send ⇒ Object
The implementation of sending the transaction, as implemented by the subclass.
-
#initialize(*arguments) ⇒ AchTransaction
constructor
provider to use with your transaction.
-
#send ⇒ Object
Check if the transaction is sendable, and if so, send it according to the subclass implementation.
-
#sendable? ⇒ Boolean
Prevent sending of invalid transactions, such as those where the effective entry date is in the past.
Constructor Details
#initialize(*arguments) ⇒ AchTransaction
provider to use with your transaction
45 46 47 48 49 50 51 52 53 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 45 def initialize(*arguments) args = arguments. self.class.arguments.each do |param| self.instance_variable_set( "@#{param}".to_sym, args[param] ) end end |
Class Method Details
.arguments ⇒ Array
instance attributes
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 10 def self.arguments [ :account_number, :account_type, :amount, :effective_entry_date, :external_ach_id, :memo, :merchant_name, :originator_name, :routing_number, :sec_code, :transaction_type ] end |
Instance Method Details
#credit? ⇒ Boolean
Returns true if transaction is a credit.
61 62 63 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 61 def credit? transaction_type == AchClient::TransactionTypes::Credit end |
#debit? ⇒ Boolean
Returns true if transaction is a debit.
56 57 58 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 56 def debit? transaction_type == AchClient::TransactionTypes::Debit end |
#do_send ⇒ Object
The implementation of sending the transaction, as implemented by the
subclass
77 78 79 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 77 def do_send raise AbstractMethodError end |
#send ⇒ Object
Check if the transaction is sendable, and if so, send it according
to the subclass implementation
67 68 69 70 71 72 73 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 67 def send if sendable? do_send else raise InvalidAchTransactionError end end |
#sendable? ⇒ Boolean
Prevent sending of invalid transactions, such as those where the
effective entry date is in the past
83 84 85 |
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 83 def sendable? effective_entry_date&.future? || effective_entry_date&.today? end |