From 71e041c2e9811721b6dc560592deba65106c2b88 Mon Sep 17 00:00:00 2001 From: Jacob Zaval Date: Thu, 19 Oct 2023 13:52:02 -0700 Subject: [PATCH] fix missing borrowed helper method --- resources/defaults.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/resources/defaults.rb b/resources/defaults.rb index ab69eb3..399b561 100644 --- a/resources/defaults.rb +++ b/resources/defaults.rb @@ -9,6 +9,31 @@ property :settings, Hash property :system, [true, false] property :user, String +action_class do + def convert_to_string_from_data_type(value) + case value + when Array + "-array #{value.map { |x| convert_to_string_from_data_type(x) }.join(' ')}" + when Integer + "-integer #{value}" + when FalseClass + "-bool #{value}" + when TrueClass + "-bool #{value}" + when Hash + "-dict #{value.map do |k, v| + Shellwords.shellescape(k) + ' ' + convert_to_string_from_data_type(v) + end.join(' ')}" + when String + "-string #{Shellwords.shellescape(value)}" + when Float + "-float #{value}" + else + raise "Unknown or unsupported data type: #{value} of #{value.class}" + end + end +end + action :run do new_resource.option = 'read' if new_resource.read_only new_resource.settings.each do |setting, value|