Class: AchClient::ReturnCodes

Inherits:
Object
  • Object
show all
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

Class Method Details

.allArray<AchClient::ReturnCode>

Returns A list of all return codes.

Returns:



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ach_client/objects/return_codes.rb', line 11

def self.all
  self._return_codes ||= YAML.load_file(
    File.expand_path(File.join(File.dirname(__FILE__), RETURN_CODES_YAML))
  ).map do |code|
    ReturnCode.new(
      code: code['code'],
      description: code['description'],
      reason: code['reason']
    )
  end
end

.find_by(code:) ⇒ Object

Finds the first ReturnCode with the given code, or raises an exception.

Parameters:

  • 3 (String)

    char code identifier for a return code

  • The (AchClient::ReturnCode)

    ReturnCode object with that code



26
27
28
29
30
31
# File 'lib/ach_client/objects/return_codes.rb', line 26

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