Module: RepsClient::Configuration

Includes:
Configlet
Included in:
RepsClient
Defined in:
lib/reps_client/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerLogger

Returns the logger to use for debug messages (defaults to STDOUT).

Returns:

  • (Logger)

    the logger to use for debug messages (defaults to STDOUT)



54
55
56
# File 'lib/reps_client/configuration.rb', line 54

def logger
  @logger ||= Logger.new(STDOUT)
end

Class Method Details

.extended(base) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/reps_client/configuration.rb', line 18

def self.extended(base)
  # Default configuration - happens whether or not .configure is called
  base.config :reps_client do
    default :endpoint => DEFAULT_ENDPOINT
    default :namespace => DEFAULT_NAMESPACE
    default :debug => 'false'
  end
end

Instance Method Details

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

Configures this module through the given block. Default configuration options will be applied unless they are explicitly overridden in the block.

Examples:

Typical case utilizing defaults

RepsClient.configure do |config|
  config.username = 'my_user'
  config.password = 'my_pass'
  config.enterprise_key = 'my_key'
end

Overriding defaults

RepsClient.configure do |config|
  config.username = 'my_user'
  config.password = 'my_pass'
  config.endpoint = 'http://my.endpoint.com'
  config.namespace = 'http://my.namespace.com'
  config.enterprise_key = 'my_key'
  config.debug = true
  config.logger = Logger.new('my.log')
end

Yields:

  • (_self)

    configures service connection options

Yield Parameters:

  • _self (YieldstarClient)

    the object on which the configure method was called

Returns:

See Also:



82
83
84
85
86
87
88
# File 'lib/reps_client/configuration.rb', line 82

def configure
  config :reps_client do
    yield self
  end

  self
end

#debug?true, false

Returns true if debug logging is enabled; false otherwie.

Returns:

  • (true, false)

    true if debug logging is enabled; false otherwie.



46
47
48
# File 'lib/reps_client/configuration.rb', line 46

def debug?
  self[:debug] == 'true'
end

#optionsHash<Symbol,Object>

Create a hash of configuration options and their values.

Returns:

  • (Hash<Symbol,Object>)

    the options hash



94
95
96
97
98
# File 'lib/reps_client/configuration.rb', line 94

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

#resetObject

Resets this module’s configuration. Configuration options will be set to default values if they exist; otherwise, they will be set to nil.



107
108
109
# File 'lib/reps_client/configuration.rb', line 107

def reset
  VALID_CONFIG_OPTIONS.each { |opt| self.send("#{opt}=", nil) } 
end