Class: Chef::Provider
- Extended by:
- Mixin::ConvertToClassName
- Includes:
- Mixin::RecipeDefinitionDSLCore
- Defined in:
- lib/chef/provider.rb,
lib/chef/provider/git.rb,
lib/chef/provider/cron.rb,
lib/chef/provider/file.rb,
lib/chef/provider/link.rb,
lib/chef/provider/user.rb,
lib/chef/provider/group.rb,
lib/chef/provider/mdadm.rb,
lib/chef/provider/mount.rb,
lib/chef/provider/route.rb,
lib/chef/provider/deploy.rb,
lib/chef/provider/script.rb,
lib/chef/provider/execute.rb,
lib/chef/provider/package.rb,
lib/chef/provider/service.rb,
lib/chef/provider/user/pw.rb,
lib/chef/provider/erl_call.rb,
lib/chef/provider/group/pw.rb,
lib/chef/provider/ifconfig.rb,
lib/chef/provider/template.rb,
lib/chef/provider/directory.rb,
lib/chef/provider/user/dscl.rb,
lib/chef/provider/breakpoint.rb,
lib/chef/provider/group/dscl.rb,
lib/chef/provider/ruby_block.rb,
lib/chef/provider/subversion.rb,
lib/chef/provider/mount/mount.rb,
lib/chef/provider/package/apt.rb,
lib/chef/provider/package/rpm.rb,
lib/chef/provider/package/yum.rb,
lib/chef/provider/remote_file.rb,
lib/chef/provider/http_request.rb,
lib/chef/provider/package/dpkg.rb,
lib/chef/provider/service/init.rb,
lib/chef/provider/user/useradd.rb,
lib/chef/provider/group/gpasswd.rb,
lib/chef/provider/group/usermod.rb,
lib/chef/provider/group/groupadd.rb,
lib/chef/provider/package/zypper.rb,
lib/chef/provider/service/debian.rb,
lib/chef/provider/service/redhat.rb,
lib/chef/provider/service/simple.rb,
lib/chef/provider/deploy/revision.rb,
lib/chef/provider/package/freebsd.rb,
lib/chef/provider/package/portage.rb,
lib/chef/provider/service/freebsd.rb,
lib/chef/provider/package/macports.rb,
lib/chef/provider/package/rubygems.rb,
lib/chef/provider/remote_directory.rb,
lib/chef/provider/deploy/timestamped.rb,
lib/chef/provider/package/easy_install.rb
Direct Known Subclasses
Breakpoint, Cron, Deploy, ErlCall, Execute, File, Git, Group, HttpRequest, Ifconfig, Link, Mdadm, Mount, Package, Route, RubyBlock, Service, Subversion, User
Defined Under Namespace
Classes: Breakpoint, Cron, Deploy, Directory, ErlCall, Execute, File, Git, Group, HttpRequest, Ifconfig, Link, Mdadm, Mount, Package, RemoteDirectory, RemoteFile, Route, RubyBlock, Script, Service, Subversion, Template, User
Instance Attribute Summary collapse
-
#current_resource ⇒ Object
Returns the value of attribute current_resource.
-
#new_resource ⇒ Object
Returns the value of attribute new_resource.
-
#node ⇒ Object
Returns the value of attribute node.
Class Method Summary collapse
Instance Method Summary collapse
- #action_nothing ⇒ Object
-
#initialize(node, new_resource, collection = nil, definitions = {}, cookbook_loader = nil) ⇒ Provider
constructor
A new instance of Provider.
- #load_current_resource ⇒ Object
Methods included from Mixin::ConvertToClassName
convert_to_class_name, convert_to_snake_case, filename_to_qualified_string
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #search, #value_for_platform
Constructor Details
#initialize(node, new_resource, collection = nil, definitions = {}, cookbook_loader = nil) ⇒ Provider
Returns a new instance of Provider.
31 32 33 34 35 36 37 38 39 |
# File 'lib/chef/provider.rb', line 31 def initialize(node, new_resource, collection=nil, definitions={}, cookbook_loader=nil) @node = node @new_resource = new_resource @current_resource = nil @collection = collection @definitions = definitions @cookbook_loader = cookbook_loader @cookbook_name = @new_resource.cookbook_name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
Instance Attribute Details
#current_resource ⇒ Object
Returns the value of attribute current_resource.
29 30 31 |
# File 'lib/chef/provider.rb', line 29 def current_resource @current_resource end |
#new_resource ⇒ Object
Returns the value of attribute new_resource.
29 30 31 |
# File 'lib/chef/provider.rb', line 29 def new_resource @new_resource end |
#node ⇒ Object
Returns the value of attribute node.
29 30 31 |
# File 'lib/chef/provider.rb', line 29 def node @node end |
Class Method Details
.build_from_file(cookbook_name, filename) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/chef/provider.rb', line 66 def build_from_file(cookbook_name, filename) pname = filename_to_qualified_string(cookbook_name, filename) new_provider_class = Class.new self do |cls| def load_current_resource # silence Chef::Exceptions::Override exception end class << cls include Chef::Mixin::FromFile # setup DSL's shortcut methods def action(name, &block) define_method("action_#{name.to_s}") do instance_eval(&block) end end end # load provider definition from file cls.class_from_file(filename) end # register new class as a Chef::Provider pname = filename_to_qualified_string(cookbook_name, filename) class_name = convert_to_class_name(pname) Chef::Provider.const_set(class_name, new_provider_class) Chef::Log.debug("Loaded contents of #{filename} into a provider named #{pname} defined in Chef::Provider::#{class_name}") new_provider_class end |
Instance Method Details
#action_nothing ⇒ Object
45 46 47 48 |
# File 'lib/chef/provider.rb', line 45 def action_nothing Chef::Log.debug("Doing nothing for #{@new_resource.to_s}") true end |
#load_current_resource ⇒ Object
41 42 43 |
# File 'lib/chef/provider.rb', line 41 def load_current_resource raise Chef::Exceptions::Override, "You must override load_current_resource in #{self.to_s}" end |