Sha256: 039b759442047602aa076b4590a71c132b856113e6b7b8d1ae7e9f424d2f607b
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true require_relative 'configuration' class Valvat class Options DEPRECATED_KEYS = { requester_vat: :requester, savon: :http }.freeze def initialize(options, silence: false) @options = options || {} DEPRECATED_KEYS.each do |deprecated, key| if @options.key?(deprecated) puts "DEPRECATED: The option :#{deprecated} is deprecated. Use :#{key} instead." unless silence @options[key] ||= @options[deprecated] end end check_uk_key end def [](key) @options.key?(key) ? @options[key] : Valvat.config[key] end def dig(*keys) @options.dig(*keys).nil? ? Valvat.config.dig(*keys) : @options.dig(*keys) end private def check_uk_key return if @options[:uk] != true || silence puts 'DEPRECATED: The option :uk is not allowed to be set to `true` anymore. ' \ 'Using the HMRC API requires authentication credentials.' end end def self.Options(options) options.is_a?(Valvat::Options) ? options : Valvat::Options.new(options) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valvat-2.0.0 | lib/valvat/options.rb |