Sha256: 07cfa2f3afd26d228ed66c2891d479bb3dc68d72ff9b35bf2dc30aafb27eadcf
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
module AchClient # Finding and listing all Ach return codes class ReturnCodes # The path to the file where the return codes are enumerated RETURN_CODES_YAML = '../../../config/return_codes.yml' class_attribute :_return_codes # @return [Array<AchClient::ReturnCode>] A list of all return codes. 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'], risk_and_enforcement_category: code['risk_and_enforcement_category'] ) end end def self.unauthorized self.all.select(&:unauthorized_return?) end def self.administrative self.all.select(&:administrative_return?) end # Finds the first ReturnCode with the given code, or raises an exception. # @param [String] 3 char code identifier for a return code # @param [AchClient::ReturnCode] The ReturnCode object with that code 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 end end
Version data entries
6 entries across 6 versions & 1 rubygems