summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-03-29 09:49:59 -0700
committerAdam Edwards <adamed@opscode.com>2014-03-29 09:49:59 -0700
commit43b3f4c0a48a5f6a5c242bb649f72239197b0097 (patch)
tree268112dd378aa7234f474e46efee1a97bcfaf12e /lib
parent7d4f5e04ce9851dce6f97c72ffee8b2cca2b58bc (diff)
downloadchef-43b3f4c0a48a5f6a5c242bb649f72239197b0097.tar.gz
CR feedback: fix misleading method name for setting inheritance, validate class inheritance prior to instantiation
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb8
-rw-r--r--lib/chef/resource/powershell_script.rb2
-rw-r--r--lib/chef/resource/script.rb7
3 files changed, 8 insertions, 9 deletions
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index fc1d4a1df8..229a8502c7 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -79,14 +79,14 @@ class Chef
raise ArgumentError, "Specified guard_interpreter resource #{parent_resource.guard_interpreter.to_s} unknown for this platform"
end
+ if ! resource_class.ancestors.include?(Chef::Resource::Script)
+ raise ArgumentError, "Specified guard interpreter class #{resource_class} must be a kind of Chef::Resource::Script resource"
+ end
+
empty_events = Chef::EventDispatch::Dispatcher.new
anonymous_run_context = Chef::RunContext.new(parent_resource.node, {}, empty_events)
interpreter_resource = resource_class.new('Guard resource', anonymous_run_context)
- if ! interpreter_resource.kind_of?(Chef::Resource::Script)
- raise ArgumentError, "Specified guard interpreter class #{resource_class} must be a kind of Chef::Resource::Script resource"
- end
-
interpreter_resource
end
diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb
index f053d0b2aa..1b47e7411a 100644
--- a/lib/chef/resource/powershell_script.rb
+++ b/lib/chef/resource/powershell_script.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class PowershellScript < Chef::Resource::WindowsScript
- add_guard_inherited_attributes(:architecture)
+ set_guard_inherited_attributes(:architecture)
def initialize(name, run_context=nil)
super(name, run_context, :powershell_script, "powershell.exe")
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
index 6ef74ce77a..6f66fb9094 100644
--- a/lib/chef/resource/script.rb
+++ b/lib/chef/resource/script.rb
@@ -58,9 +58,8 @@ class Chef
)
end
- def self.add_guard_inherited_attributes(*inherited_attributes)
- @class_inherited_attributes ||= []
- @class_inherited_attributes = inherited_attributes if inherited_attributes
+ def self.set_guard_inherited_attributes(*inherited_attributes)
+ @class_inherited_attributes = inherited_attributes
end
def self.guard_inherited_attributes(*inherited_attributes)
@@ -75,7 +74,7 @@ class Chef
ancestor_attributes.concat(@class_inherited_attributes ? @class_inherited_attributes : []).uniq
end
- add_guard_inherited_attributes(
+ set_guard_inherited_attributes(
:cwd,
:environment,
:group,