Class: Chef::Resource::RegistryKey
- Inherits:
-
Chef::Resource
- Object
- Chef::Resource
- Chef::Resource::RegistryKey
- Defined in:
- lib/chef/resource/registry_key.rb
Constant Summary
Constants inherited from Chef::Resource
Instance Attribute Summary
Attributes inherited from Chef::Resource
#allowed_actions, #cookbook_name, #elapsed_time, #enclosing_provider, #not_if_args, #only_if_args, #params, #provider, #recipe_name, #resource_name, #retries, #retry_delay, #run_context, #source_line, #updated
Instance Method Summary collapse
- #architecture(arg = nil) ⇒ Object
-
#initialize(name, run_context = nil) ⇒ RegistryKey
constructor
A new instance of RegistryKey.
- #key(arg = nil) ⇒ Object
- #recursive(arg = nil) ⇒ Object
- #values(arg = nil) ⇒ Object
Methods inherited from Chef::Resource
#action, #after_created, #as_json, #cookbook_version, #customize_exception, #defined_at, #delayed_notifications, dsl_name, #epic_fail, #events, find_subclass_by_name, #identity, identity_attr, #ignore_failure, #immediate_notifications, inherited, #inspect, #is, json_create, #load_prior_resource, #method_missing, #name, #node, #noop, #not_if, #notifies, #notifies_delayed, #notifies_immediately, #only_if, platform_map, provider_base, #provider_for_action, provides, #resolve_notification_references, resource_classes, resource_for_node, resource_for_platform, #resources, #run_action, #should_skip?, #state, state_attrs, #subscribes, #supports, #to_hash, #to_json, #to_s, #to_text, #updated?, #updated_by_last_action, #updated_by_last_action?, #validate_action
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::Deprecation
Methods included from DSL::RegistryHelper
#registry_data_exists?, #registry_get_subkeys, #registry_get_values, #registry_has_subkeys?, #registry_key_exists?, #registry_value_exists?
Methods included from DSL::PlatformIntrospection
#platform?, #platform_family?, #value_for_platform, #value_for_platform_family
Methods included from Mixin::ParamsValidate
Methods included from DSL::DataQuery
#data_bag, #data_bag_item, #search
Constructor Details
#initialize(name, run_context = nil) ⇒ RegistryKey
Returns a new instance of RegistryKey.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chef/resource/registry_key.rb', line 28 def initialize(name, run_context=nil) super @resource_name = :registry_key @action = :create @architecture = :machine @recursive = false @key = name @values = [] @allowed_actions.push(:create, :create_if_missing, :delete, :delete_key) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Resource
Instance Method Details
#architecture(arg = nil) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/chef/resource/registry_key.rb', line 76 def architecture(arg=nil) set_or_return( :architecture, arg, :kind_of => Symbol ) end |
#key(arg = nil) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/chef/resource/registry_key.rb', line 39 def key(arg=nil) set_or_return( :key, arg, :kind_of => String ) end |
#recursive(arg = nil) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/chef/resource/registry_key.rb', line 69 def recursive(arg=nil) set_or_return( :recursive, arg, :kind_of => [TrueClass, FalseClass] ) end |
#values(arg = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/resource/registry_key.rb', line 46 def values(arg=nil) if not arg.nil? if arg.is_a?(Hash) @values = [ arg ] elsif arg.is_a?(Array) @values = arg else raise ArgumentError, "Bad type for RegistryKey resource, use Hash or Array" end @values.each do |v| raise ArgumentError, "Missing name key in RegistryKey values hash" unless v.has_key?(:name) raise ArgumentError, "Missing type key in RegistryKey values hash" unless v.has_key?(:type) raise ArgumentError, "Missing data key in RegistryKey values hash" unless v.has_key?(:data) v.each_key do |key| raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name,:type,:data].include?(key) end raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String) raise Argument Error "Type of type => #{v[:name]} should be symbol" unless v[:type].is_a?(Symbol) end elsif self.instance_variable_defined?(:@values) == true @values end end |