Method: RepsClient::Client#initialize

Defined in:
lib/reps_client/client.rb

#initialize(options = {}) ⇒ Client

Initializes the client.

By default, the new client instance will take all of its configuration values from the module-level configuration, but these can be overridden at the client-level.

Examples:

Using module-level configuration values

RepsClient.configure do |config|
  config.enterprise_key = 'my_key'
end

client1 = RepsClient::Client.new
client1.enterprise_key
# => "my_key"

client2 = RepsClient::Client.new
client2.enterprise_key
# => "my_key"

Selectively overriding configuration values at the client level

RepsClient.configure do |config|
  config.enterprise_key = 'my_key'
  config.debug = 'true'
end

client1 = RepsClient::Client.new
client1.enterprise_key
# => "my_key"
client1.debug?
# => true

client2 = RepsClient::Client.new(:debug => false)
client2.enterprise_key
# => "my_key"
client2.debug?
# => false

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :username (String)

    The username for authenticating to the web service

  • :password (String)

    The password for authenticating to the web service

  • :enterprise_key (String)

    The enterprise key for authentication to the web service

  • :endpoint (String)

    The address for connecting to the web service

  • :namespace (String)

    The XML namespace to use for requests

  • :debug (true, false)

    true enabled debug logging (defaults to false)

  • :logger (Logger)

    a custom logger instance (defaults to STDOUT)

See Also:



91
92
93
94
95
# File 'lib/reps_client/client.rb', line 91

def initialize(options={})
  self.debug = nil
  self.logger = nil
  options.each { |k,v| self.send("#{k}=", v) if self.respond_to?("#{k}=") }
end