Module: Chef::DSL::Resources Private

Includes:
ChefProvisioning, Cheffish
Included in:
Recipe
Defined in:
lib/chef/dsl/resources.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Module containing a method for each globally declared Resource

Depends on declare_resource(name, created_at, &block)

Class Method Summary collapse

Methods included from ChefProvisioning

load_chef_provisioning

Methods included from Cheffish

load_cheffish

Class Method Details

.add_resource_dsl(dsl_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/dsl/resources.rb', line 35

def self.add_resource_dsl(dsl_name)
  begin
    module_eval(<<-EOM, __FILE__, __LINE__ + 1)
      def #{dsl_name}(*args, &block)
        Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1
        declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block)
      end
    EOM
  rescue SyntaxError
    # Handle the case where dsl_name has spaces, etc.
    define_method(dsl_name.to_sym) do |*args, &block|
      Chef.log_deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1
      declare_resource(dsl_name, args[0], caller[0], &block)
    end
  end
end

.remove_resource_dsl(dsl_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
# File 'lib/chef/dsl/resources.rb', line 52

def self.remove_resource_dsl(dsl_name)
  remove_method(dsl_name)
rescue NameError
end