Sha256: 05eb5989f7900755ae2c94fb1b7778c1d221b7ea1facfca0b6358895a6162637

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

module Bs2Api
  module Util
    class BankService
      class << self
        def find_by_code code
          bank = bank_list.find {|b| b["code"] == code }
          raise Bs2Api::Errors::MissingBank, "Bank with code #{code} not registered into util/banks.yml file" if bank.blank?
          bank
        end

        def bank_list
          @bank_list ||= YAML.load_file(File.join(__dir__, 'banks.yml'))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bs2_api-1.1.0 lib/bs2_api/util/bank_service.rb