Module: Einvoice::Configuration

Included in:
Einvoice
Defined in:
lib/einvoice/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :endpoint,
  :endpoint_url,
  :client_id,
  :client_secret,
  :encryption_keys,
  :format
].freeze
DEFAULT_CLIENT_ID =
nil
DEFAULT_CLIENT_SECRET =
nil
DEFAULT_ENDPOINT =
"".freeze
DEFAULT_ENDPOINT_URL =
nil
DEFAULT_FORMAT =
""
DEFAULT_ENCRYPTION_KEYS =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



23
24
25
# File 'lib/einvoice/configuration.rb', line 23

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



27
28
29
# File 'lib/einvoice/configuration.rb', line 27

def configure
  yield self
end

#optionsObject



31
32
33
34
35
# File 'lib/einvoice/configuration.rb', line 31

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

#resetObject



37
38
39
40
41
42
43
44
# File 'lib/einvoice/configuration.rb', line 37

def reset
  self.client_id       = DEFAULT_CLIENT_ID
  self.client_secret   = DEFAULT_CLIENT_SECRET
  self.endpoint        = DEFAULT_ENDPOINT
  self.endpoint_url    = DEFAULT_ENDPOINT_URL
  self.encryption_keys = DEFAULT_ENCRYPTION_KEYS
  self.format          = DEFAULT_FORMAT
end