diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-07-16 23:50:23 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-07-20 11:45:27 -0700 |
commit | 54abeb9cc238998d70d93429b79aebde9d8f2da4 (patch) | |
tree | fcb1e6cd5ee74356694cda36dc7d5a5cbf04b38d /lib | |
parent | 5535bfd5f8d200dd841ac2a69c637acfa57781e2 (diff) | |
download | chef-54abeb9cc238998d70d93429b79aebde9d8f2da4.tar.gz |
Use concat in another place
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/macos_userdefaults.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb index 84c0c3dd65..d116393f65 100644 --- a/lib/chef/resource/macos_userdefaults.rb +++ b/lib/chef/resource/macos_userdefaults.rb @@ -173,17 +173,22 @@ class Chef cmd = ["defaults"] if new_resource.host == "current" - state_cmd << "-currentHost" + state_cmd.concat(["-currentHost"]) elsif new_resource.host # they specified a non-nil value, which is a hostname - state_cmd << ["-host", new_resource.host] + state_cmd.concat(["-host", new_resource.host]) end - cmd << [defaults_action, new_resource.domain, new_resource.key] - cmd << processed_value if defaults_action == "write" + cmd.concat([defaults_action, new_resource.domain, new_resource.key]) + cmd.concat(processed_value) if defaults_action == "write" cmd.prepend("sudo") if new_resource.sudo - cmd.flatten + cmd end + # + # convert the provided value into the format defaults expects + # + # @return [array] array of values starting with the type if applicable + # def processed_value type = new_resource.type || value_type(value) @@ -192,6 +197,13 @@ class Chef cmd_vals.prepend("-#{type}") if type end + # + # convert ruby type to defaults type + # + # @param [Integer, Float, String, TrueClass, FalseClass, Hash, Array] value The value being set + # + # @return [string, nil] the type value used by defaults or nil if not applicable + # def value_type(value) case value when true, false |