Module: Payture::Configuration

Included in:
Payture
Defined in:
lib/payture/configuration.rb

Constant Summary collapse

DOMAIN =
'payture.com'
VALID_OPTIONS_KEYS =
[
  :api_type,
  :host_type,
  :key,
  :password,
  :format,
  :user_agent,
  :adapter
].freeze
DEFAULT_API_TYPE =
'vwapi'
DEFAULT_HOST_TYPE =
'sandbox'
DEFAULT_KEY =
'VWMerchant'
DEFAULT_PASSWORD =
nil
DEFAULT_USER_AGENT =
"Payture Ruby Gem #{Payture::VERSION}".freeze
DEFAULT_FORMAT =
'xml'
DEFAULT_ADAPTER =
Faraday.default_adapter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



31
32
33
# File 'lib/payture/configuration.rb', line 31

def self.extended(base)
  base.reset
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



36
37
38
# File 'lib/payture/configuration.rb', line 36

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



41
42
43
44
45
# File 'lib/payture/configuration.rb', line 41

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

#resetObject

Reset all configuration options to defaults



48
49
50
51
52
53
54
55
56
# File 'lib/payture/configuration.rb', line 48

def reset
  self.adapter = DEFAULT_ADAPTER
  self.api_type = DEFAULT_API_TYPE
  self.host_type = DEFAULT_HOST_TYPE
  self.key = DEFAULT_KEY
  self.password = DEFAULT_PASSWORD
  self.user_agent = DEFAULT_USER_AGENT
  self.format = DEFAULT_FORMAT
end