From 751bd6577681aa3d5db9273c4edb007e8136f940 Mon Sep 17 00:00:00 2001 From: mwrock Date: Thu, 1 Oct 2020 17:20:52 -0700 Subject: use class method instead of class var Signed-off-by: mwrock --- lib/chef/pwsh.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/chef/pwsh.rb') diff --git a/lib/chef/pwsh.rb b/lib/chef/pwsh.rb index d7604b4422..41087e3541 100644 --- a/lib/chef/pwsh.rb +++ b/lib/chef/pwsh.rb @@ -18,8 +18,6 @@ class Chef class Pwsh < Chef::PowerShell - @@wrapper_dll ||= Dir.glob("#{RbConfig::CONFIG["bindir"]}/**/Chef.PowerShell.Wrapper.Core.dll").last - # Run a command under pwsh (powershell core) via FFI # This implementation requires the managed dll, native wrapper and a # published, self contained dotnet core directory tree to exist in the @@ -28,7 +26,7 @@ class Chef # @param script [String] script to run # @return [Object] output def initialize(script) - @dll = @@wrapper_dll + @dll = Pwsh.dll super end @@ -55,5 +53,9 @@ class Chef ENV["DOTNET_MULTILEVEL_LOOKUP"] = original_dml ENV["DOTNET_ROOT"] = original_dotnet_root end + + def self.dll + @dll ||= Dir.glob("#{RbConfig::CONFIG["bindir"]}/**/Chef.PowerShell.Wrapper.Core.dll").last + end end end -- cgit v1.2.1