Sha256: bc6c9b8252074f54d56da472103a32603f4eeea1f3b63a85a20015ab8a0504d4

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 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 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

2 entries across 2 versions & 1 rubygems

Version Path
bs2_api-1.0.3 lib/bs2_api/util/bank_service.rb
bs2_api-1.0.2 lib/bs2_api/util/bank_service.rb