Sha256: 816bd9a2379d234640463b8d910965da77125175379d84d04a067f3248ecd9f2

Contents?: true

Size: 495 Bytes

Versions: 8

Compression:

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bs2_api-1.0.1 lib/bs2_api/util/bank_service.rb
bs2_api-1.0.0 lib/bs2_api/util/bank_service.rb
bs2_api-0.4.0 lib/bs2_api/util/bank_service.rb
bs2_api-0.3.4 lib/bs2_api/util/bank_service.rb
bs2_api-0.3.3 lib/bs2_api/util/bank_service.rb
bs2_api-0.3.2 lib/bs2_api/util/bank_service.rb
bs2_api-0.3.1 lib/bs2_api/util/bank_service.rb
bs2_api-0.3.0 lib/bs2_api/util/bank_service.rb