Class: AchClient::ReturnCodes
- Inherits:
-
Object
- Object
- AchClient::ReturnCodes
- Defined in:
- lib/ach_client/objects/return_codes.rb
Overview
Finding and listing all Ach return codes
Constant Summary collapse
- RETURN_CODES_YAML =
The path to the file where the return codes are enumerated
'../../../config/return_codes.yml'
Class Method Summary collapse
- .administrative ⇒ Object
-
.all ⇒ Array<AchClient::ReturnCode>
A list of all return codes.
-
.find_by(code:) ⇒ Object
Finds the first ReturnCode with the given code, or raises an exception.
- .unauthorized ⇒ Object
Class Method Details
.administrative ⇒ Object
28 29 30 |
# File 'lib/ach_client/objects/return_codes.rb', line 28 def self.administrative self.all.select(&:administrative_return?) end |
.all ⇒ Array<AchClient::ReturnCode>
Returns A list of all return codes.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ach_client/objects/return_codes.rb', line 11 def self.all self._return_codes ||= YAML.load_file( File.(File.join(File.dirname(__FILE__), RETURN_CODES_YAML)) ).map do |code| ReturnCode.new( code: code['code'], description: code['description'], reason: code['reason'], risk_and_enforcement_category: code['risk_and_enforcement_category'] ) end end |
.find_by(code:) ⇒ Object
Finds the first ReturnCode with the given code, or raises an exception.
35 36 37 38 39 40 |
# File 'lib/ach_client/objects/return_codes.rb', line 35 def self.find_by(code:) self.all.find do |return_code| return_code.code == code # For some reason || is bad syntax in this context end or raise "Could not find return code #{code}" end |
.unauthorized ⇒ Object
24 25 26 |
# File 'lib/ach_client/objects/return_codes.rb', line 24 def self. self.all.select(&:unauthorized_return?) end |