Module: DisplayWords::Configuration

Included in:
DisplayWords
Defined in:
lib/display_words/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:username, :password, :domain, :format]
VALID_FORMATS =
[:json]
DEFAULT_DOMAIN =
'http://hb.sand-08.adnxs.net/'
DEFAULT_FORMAT =
'json'

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



12
13
14
15
# File 'lib/display_words/configuration.rb', line 12

def self.extended(base)
  base.reset
  self
end

Instance Method Details

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

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

Yields:

  • (_self)

Yield Parameters:



18
19
20
# File 'lib/display_words/configuration.rb', line 18

def configure
  yield self
end

#options ⇒ Object

Create a hash of options and their values



23
24
25
26
27
# File 'lib/display_words/configuration.rb', line 23

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
  options
end

#reset ⇒ Object

Reset all configuration options to defaults



30
31
32
33
34
# File 'lib/display_words/configuration.rb', line 30

def reset
  self.domain = DEFAULT_DOMAIN
  self.format = DEFAULT_FORMAT
  self
end