diff options
author | rishichawda <rishichawda@users.noreply.github.com> | 2021-10-01 21:59:19 +0530 |
---|---|---|
committer | rishichawda <rishichawda@users.noreply.github.com> | 2021-10-04 15:00:39 +0530 |
commit | 1b811ab164e9170676d67b6f88c1129e1b44f07c (patch) | |
tree | 569c4bc06651d195f9eba316bb195216e058865e | |
parent | a7c2dd6ec89b4f36e00b2a5cd60a124639203e9f (diff) | |
download | chef-1b811ab164e9170676d67b6f88c1129e1b44f07c.tar.gz |
require CF in action_class
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r-- | lib/chef/resource/macos_userdefaults.rb | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb index b0b9c32fe0..ee84278392 100644 --- a/lib/chef/resource/macos_userdefaults.rb +++ b/lib/chef/resource/macos_userdefaults.rb @@ -17,7 +17,6 @@ require_relative "../resource" require "chef-utils/dist" unless defined?(ChefUtils::Dist) -require "corefoundation" if RUBY_PLATFORM.match?(/darwin/) autoload :Plist, "plist" class Chef @@ -136,27 +135,31 @@ class Chef CF::Preferences.get(new_resource.key, new_resource.domain, new_resource.user, new_resource.host) end - # Return valid hostname based on the input from host property - def to_cf_host(value) - case value - when :all - CF::Preferences::ALL_HOSTS - when :current - CF::Preferences::CURRENT_HOST - else - value + action_class do + require "corefoundation" if RUBY_PLATFORM.match?(/darwin/) + + # Return valid hostname based on the input from host property + def to_cf_host(value) + case value + when :all + CF::Preferences::ALL_HOSTS + when :current + CF::Preferences::CURRENT_HOST + else + value + end end - end - # Return valid username based on the input from user property - def to_cf_user(value) - case value - when :all - CF::Preferences::ALL_USERS - when :current - CF::Preferences::CURRENT_USER - else - value + # Return valid username based on the input from user property + def to_cf_user(value) + case value + when :all + CF::Preferences::ALL_USERS + when :current + CF::Preferences::CURRENT_USER + else + value + end end end end |