Module: ChefAPI

Extended by:
Configurable
Defined in:
lib/chef-api.rb,
lib/chef-api/util.rb,
lib/chef-api/errors.rb,
lib/chef-api/schema.rb,
lib/chef-api/boolean.rb,
lib/chef-api/version.rb,
lib/chef-api/defaults.rb,
lib/chef-api/resource.rb,
lib/chef-api/validator.rb,
lib/chef-api/connection.rb,
lib/chef-api/configurable.rb,
lib/chef-api/resources/base.rb,
lib/chef-api/resources/node.rb,
lib/chef-api/resources/role.rb,
lib/chef-api/resources/user.rb,
lib/chef-api/validators/base.rb,
lib/chef-api/validators/type.rb,
lib/chef-api/error_collection.rb,
lib/chef-api/resources/client.rb,
lib/chef-api/resources/cookbook.rb,
lib/chef-api/resources/data_bag.rb,
lib/chef-api/resources/data_bag.rb,
lib/chef-api/resources/principal.rb,
lib/chef-api/validators/required.rb,
lib/chef-api/resources/environment.rb,
lib/chef-api/resources/organization.rb,
lib/chef-api/resources/data_bag_item.rb,
lib/chef-api/resources/collection_proxy.rb,
lib/chef-api/resources/cookbook_version.rb

Defined Under Namespace

Modules: Boolean, Configurable, Defaults, Error, Resource, Util, Validator Classes: Connection, ErrorCollection, Schema

Constant Summary collapse

UNSET =
TODO:

Document this and why it’s important

Object.new
VERSION =
'0.2.1'

Class Method Summary collapse

Methods included from Configurable

configure, keys, reset!

Class Method Details

.connectionChefAPI::Connection

API connection object based off the configured options in Configurable.

Returns:



66
67
68
69
70
71
72
# File 'lib/chef-api.rb', line 66

def connection
  unless @connection && @connection.same_options?(options)
    @connection = ChefAPI::Connection.new(options)
  end

  @connection
end

.log_levelSymbol

Get the current log level.

Returns:

  • (Symbol)


47
48
49
# File 'lib/chef-api.rb', line 47

def log_level
  Logify.level
end

.log_level=(level) ⇒ Object

Set the log level.

Examples:

Set the log level to :info

ChefAPI.log_level = :info

Parameters:

  • level (Symbol)

    the log level to set



38
39
40
# File 'lib/chef-api.rb', line 38

def log_level=(level)
  Logify.level = level
end

.method_missing(m, *args, &block) ⇒ Object

Delegate all methods to the connection object, essentially making the module object behave like a Connection.



78
79
80
81
82
83
84
# File 'lib/chef-api.rb', line 78

def method_missing(m, *args, &block)
  if connection.respond_to?(m)
    connection.send(m, *args, &block)
  else
    super
  end
end

.respond_to_missing?(m, include_private = false) ⇒ Boolean

Delegating respond_to to the Connection.

Returns:



89
90
91
# File 'lib/chef-api.rb', line 89

def respond_to_missing?(m, include_private = false)
  connection.respond_to?(m) || super
end

.rootPathname

The source root of the ChefAPI gem. This is useful when requiring files that are relative to the root of the project.

Returns:

  • (Pathname)


57
58
59
# File 'lib/chef-api.rb', line 57

def root
  @root ||= Pathname.new(File.expand_path('../../', __FILE__))
end