Sha256: 98a2b5c220a44404b9136d0234e262e0089a19d70d0ffad3fa335b1d011d380a

Contents?: true

Size: 738 Bytes

Versions: 5

Compression:

Stored size: 738 Bytes

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
    end

    def [](key)
      @options.key?(key) ? @options[key] : Valvat.config[key]
    end
  end

  def self.Options(options)
    options.is_a?(Valvat::Options) ? options : Valvat::Options.new(options)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
valvat-1.4.4 lib/valvat/options.rb
valvat-1.4.3 lib/valvat/options.rb
valvat-1.4.2 lib/valvat/options.rb
valvat-1.4.1 lib/valvat/options.rb
valvat-1.4.0 lib/valvat/options.rb