Module: YieldStarClient::Configuration

Includes:
Configlet
Included in:
YieldStarClient
Defined in:
lib/yield_star_client/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject



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

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

Class Method Details

.extended(base) ⇒ Object



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

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

Instance Method Details

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

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

YieldStarClient.configure do |config|
  config.username = 'my_user'
  config.password = 'my_pass'
  config.client_name = 'my_client'
end

Overriding defaults

YieldStarClient.configure do |config|
  config.username = 'my_user'
  config.password = 'my_pass'
  config.client_name = 'my_client'
  config.endpoint = 'http://my.endpoint.com'
  config.namespace = 'http://my.namespace.com'
  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:



74
75
76
77
78
79
80
# File 'lib/yield_star_client/configuration.rb', line 74

def configure
  config :yield_star do
    yield self
  end

  self
end

#debug?Boolean

True if debug logging of SOAP requests and responses has been enabled; false otherwise.

Returns:

  • (Boolean)


39
40
41
# File 'lib/yield_star_client/configuration.rb', line 39

def debug?
  self[:debug] == 'true'
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.



89
90
91
92
# File 'lib/yield_star_client/configuration.rb', line 89

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