Commit 43b3f4c0 authored by Adam Edwards's avatar Adam Edwards
Browse files

CR feedback: fix misleading method name for setting inheritance, validate...

CR feedback: fix misleading method name for setting inheritance, validate class inheritance prior to instantiation
parent 7d4f5e04
......@@ -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
......
......@@ -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")
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment