Skip to content

Commit 68d312b

Browse files
committed
Use a more expressive method of rewriting values
This achieves almost the same, except that this version doesn't change the original value. If that's really desired, `transform_values!` can be used. It makes it clearer what's going on. It also switches to a string check and `match?` because in modern Ruby `=~` is no longer defined for arrays.
1 parent c4785ff commit 68d312b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/puppet/type/rabbitmq_parameter.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ def validate_value(value)
106106
def munge_value(value)
107107
return value if value(:autoconvert) == :false
108108

109-
value.each do |k, v|
110-
value[k] = v.to_i if v =~ %r{\A[-+]?[0-9]+\z}
111-
end
112-
value
109+
value.transform_values { |v| v.is_a?(String) && v.match?(%r{\A[-+]?[0-9]+\z}) ? v.to_i : v }
113110
end
114111
end

0 commit comments

Comments
 (0)