Skip to content

Commit 40bcc4a

Browse files
committed
Addressing review comments
1 parent 544c19a commit 40bcc4a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

functions/deferrable_epp.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# have to explicitly pass the entire scope to the client.
77
#
88
function stdlib::deferrable_epp(String $template, Hash $variables) >> Variant[String, Sensitive[String], Deferred] {
9-
if $variables.hash_values.any |$value| { $value.is_a(Deferred) } {
9+
if $variables.nested_values.any |$value| { $value.is_a(Deferred) } {
1010
Deferred(
1111
'inline_epp',
1212
[find_template($template).file, $variables],

lib/puppet/functions/hash_values.rb renamed to lib/puppet/functions/nested_values.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
# "key1" => "value1",
99
# "key2" => { "key2.1" => "value2.1"}
1010
# }
11-
# $hash.hash_value
11+
# $hash.nested_values
1212
#
1313
# Output : ["value1", "value2.1"]
1414
#
15-
Puppet::Functions.create_function(:hash_values) do
16-
dispatch :hash_values do
15+
Puppet::Functions.create_function(:nested_values) do
16+
dispatch :nested_values do
1717
param 'Hash', :options
1818
return_type 'Array'
1919
end
2020

21-
def hash_values(options)
21+
def nested_values(options)
2222
options.each_with_object([]) do |(_k, v), values|
23-
v.is_a?(Hash) ? values.concat(hash_values(v)) : (values << v)
23+
v.is_a?(Hash) ? values.concat(nested_values(v)) : (values << v)
2424
end
2525
end
2626
end

spec/functions/hash_values_spec.rb renamed to spec/functions/nested_values_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
require 'spec_helper'
44

5-
describe 'hash_values' do
5+
describe 'nested_values' do
66
# please note that these tests are examples only
77
# you will need to replace the params and return value
88
# with your expectations
99
it { is_expected.to run.with_params({}).and_return([]) }
1010
it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['value']) }
1111
it { is_expected.to run.with_params({ 'key' => { 'key1' => 'value1', 'key2' => 'value2' } }).and_return(['value1', 'value2']) }
12+
it { is_expected.to run.with_params({ 'key1' => 'value1', 'key2' => { 'key1' => 'value21', 'key2' => 'value22' }, 'key3' => 'value3' }).and_return(['value1', 'value21', 'value22', 'value3']) }
1213
it { is_expected.to run.with_params(2).and_raise_error(StandardError) }
1314
it { is_expected.to run.with_params(nil).and_raise_error(StandardError) }
1415
end

0 commit comments

Comments
 (0)