Sha256: 771dc3e0523c79123f82e0df5bf6188ee3cff0def478092c049ff629c0c07ec5
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Brazil module Cep # Adapters class namespace module Adapters # autoload default adapters autoload :Base, "brazil_cep/adapters/base" autoload :Viacep, "brazil_cep/adapters/viacep" autoload :Postmon, "brazil_cep/adapters/postmon" autoload :RepublicaVirtual, "brazil_cep/adapters/republica_virtual" # list of provider keys and classes PROVIDERS = { viacep: Viacep, postmon: Postmon, republica_virtual: RepublicaVirtual } private_constant :PROVIDERS # get providers # @return [Hash] providers def self.providers PROVIDERS end # register a provider # # @example # Brazil::Cep::Adapters.register(:custom_provider, Brazil::Cep::Adapters::CustomProvider) # # @param provider_key [Symbol] provider key # @param provider_class [Class] provider class def self.register(provider_key, provider_class) PROVIDERS[provider_key] = provider_class end # get provider instance # @param provider [Symbol] provider key # @return [Base] provider instance def self.get(provider = :viacep) PROVIDERS[provider].new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
brazil-cep-0.3.0 | lib/brazil_cep/adapters.rb |
brazil-cep-0.2.0 | lib/brazil_cep/adapters.rb |