Module: Sophos::Configuration

Includes:
WrAPI::Configuration
Included in:
Sophos, API
Defined in:
lib/sophos/configuration.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of additional valid keys in the options hash when configuring a [Sophos::API]

(WrAPI::Configuration::VALID_OPTIONS_KEYS + [:partner_id, :tenant_id, :id_endpoint]).freeze
DEFAULT_ENDPOINT =
'https://api.central.sophos.com'.freeze
DEFAULT_ID_ENDPOINT =
'https://id.sophos.com'.freeze
DEFAULT_UA =
"Sophos Ruby API wrapper #{Sophos::VERSION}".freeze
DEFAULT_PAGINATION =
Sophos::RequestPagination::PagesPagination
DEFAULT_PAGE_SIZE =
100

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



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

def self.extended(base)
  base.reset
end

Instance Method Details

#optionsObject

Create a hash of options and their values



28
29
30
31
32
# File 'lib/sophos/configuration.rb', line 28

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

#resetObject

Reset all configuration options to defaults



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sophos/configuration.rb', line 35

def reset
  super
  self.partner_id = nil
  self.tenant_id = nil

  self.endpoint = DEFAULT_ENDPOINT
  self.id_endpoint = DEFAULT_ID_ENDPOINT
  self.user_agent = DEFAULT_UA
  self.page_size = DEFAULT_PAGE_SIZE
  self.pagination_class = DEFAULT_PAGINATION
end