Sha256: 0c9c8ed0c52ceb63ad0c952d48b86233198df3109fa67033b6c351801e4be9d8

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 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 = ""

    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.2.0 lib/einvoice/configuration.rb