Module: CreditCardInfo::Proxy

Defined in:
lib/credit_card_info/proxy.rb

Class Method Summary collapse

Class Method Details

.fetch(code) ⇒ Hash, NilClass

Returns bin description.

Returns:

  • (Hash, NilClass)

    bin description



10
11
12
13
14
15
16
17
18
19
# File 'lib/credit_card_info/proxy.rb', line 10

def self.fetch(code)
  providers.each do |provider|
    response = provider.fetch(code)
    return response.data if response.valid?

    response.log_error
  end

  nil
end

.providersObject



21
22
23
24
25
26
27
28
# File 'lib/credit_card_info/proxy.rb', line 21

def self.providers
  @providers ||=
    CreditCardInfo.config.data_providers.filter_map do |name|
      Object.const_get "CreditCardInfo::Providers::#{name}"
    rescue NameError
      nil
    end
end