Module: ChefAPI

Extended by:
Configurable
Defined in:
lib/chef-api.rb,
lib/chef-api/util.rb,
lib/chef-api/proxy.rb,
lib/chef-api/errors.rb,
lib/chef-api/logger.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/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, Logger, Resource, Util, Validator Classes: Connection, ErrorCollection, Proxy, Schema

Constant Summary collapse

UNSET =
Object.new
VERSION =
'0.2.0'

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:



41
42
43
44
45
46
47
# File 'lib/chef-api.rb', line 41

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

  @connection
end

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

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



53
54
55
56
57
58
59
# File 'lib/chef-api.rb', line 53

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:



64
65
66
# File 'lib/chef-api.rb', line 64

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)


32
33
34
# File 'lib/chef-api.rb', line 32

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