Module: Slideshare::Configuration

Included in:
Slideshare
Defined in:
lib/slideshare/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :api_version,
  :api_key,
  :api_shared_secret,
  :api_http_endpoint,
  :api_https_endpoint,
  :api_response_format
].freeze
VALID_FROMATS =
[:xml].freeze
DEFAULT_API_VERSION =
"2".freeze
DEFAULT_API_KEY =
nil
DEFAULT_API_SHARED_SECRET =
nil
DEFAULT_API_HTTP_ENDPOINT =
"http://www.slideshare.net/api/2/".freeze
DEFAULT_API_HTTPS_ENDPOINT =
"https://www.slideshare.net/api/2/".freeze
DEFAULT_API_RESPONSE_FORMAT =
:xml

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



25
26
27
# File 'lib/slideshare/configuration.rb', line 25

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:



30
31
32
# File 'lib/slideshare/configuration.rb', line 30

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



35
36
37
# File 'lib/slideshare/configuration.rb', line 35

def options
  Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }]
end

#resetObject

Reset all configuration options to defaults



40
41
42
43
44
45
46
47
48
# File 'lib/slideshare/configuration.rb', line 40

def reset
  self.api_version = DEFAULT_API_VERSION
  self.api_key = DEFAULT_API_KEY
  self.api_shared_secret = DEFAULT_API_SHARED_SECRET
  self.api_http_endpoint = DEFAULT_API_HTTP_ENDPOINT
  self.api_https_endpoint = DEFAULT_API_HTTPS_ENDPOINT
  self.api_response_format = DEFAULT_API_RESPONSE_FORMAT
  self
end