Module: ChefAPI::Configurable

Included in:
ChefAPI, Connection
Defined in:
lib/chef-api/configurable.rb

Overview

A re-usable class containing configuration information for the Connection. See Defaults for a list of default values.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.keysArray<Symbol>

The list of configurable keys.

Returns:

  • (Array<Symbol>)

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/chef-api/configurable.rb', line 13

def keys
  @keys ||= [
    :endpoint,
    :flavor,
    :client,
    :key,
    :proxy_address,
    :proxy_password,
    :proxy_port,
    :proxy_username,
    :ssl_pem_file,
    :ssl_verify,
    :user_agent,
  ]
end

Instance Method Details

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

Set the configuration for this config, using a block.

Examples:

Configure the API endpoint

ChefAPI.configure do |config|
  config.endpoint = "http://www.my-ChefAPI-server.com/ChefAPI"
end

Yields:

  • (_self)

Yield Parameters:


45
46
47
# File 'lib/chef-api/configurable.rb', line 45

def configure
  yield self
end

#reset!self Also known as: setup

Reset all configuration options to their default values.

Examples:

Reset all settings

ChefAPI.reset!

Returns:

  • (self)

57
58
59
60
61
62
# File 'lib/chef-api/configurable.rb', line 57

def reset!
  ChefAPI::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Defaults.options[key])
  end
  self
end