Sha256: 55ac8893b9ecba23292496b79aa3263af9ba9ca070f8e13ccf7f9045f3d31a0b

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

require "faraday"

module Einvoice
  module Configuration
    VALID_OPTIONS_KEYS = [
      :endpoint,
      :client_id,
      :client_secret,
      :format,
    ].freeze

    DEFAULT_CLIENT_ID = nil
    DEFAULT_CLIENT_SECRET = nil
    DEFAULT_ENDPOINT = "".freeze
    DEFAULT_FORMAT = :xml

    attr_accessor *VALID_OPTIONS_KEYS

    def self.extended(base)
      base.reset
    end

    def configure
      yield self
    end

    def options
      VALID_OPTIONS_KEYS.inject({}) do |option, key|
        option.merge!(key => send(key))
      end
    end

    def reset
      self.endpoint      = DEFAULT_ENDPOINT
      self.client_id     = DEFAULT_CLIENT_ID
      self.client_secret = DEFAULT_CLIENT_SECRET
      self.format        = DEFAULT_FORMAT
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
einvoice-0.1.0 lib/einvoice/configuration.rb