Skip to content

Commit

Permalink
Rename skip_munging to autoconvert
Browse files Browse the repository at this point in the history
  • Loading branch information
joec4i committed Nov 26, 2020
1 parent e131257 commit 9e7c94b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/puppet/type/rabbitmq_parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'dest-uri' => 'amqp://remote-server',
'dest-exchange' => 'another-exchange',
},
skip_munging => true,
autoconvert => false,
}
DESC

Expand Down Expand Up @@ -62,9 +62,9 @@
end
end

newparam(:skip_munging) do
desc 'Set to true to disable conversion from number strings to integers'
defaultto(:false)
newparam(:autoconvert) do
desc 'Whether numeric strings from `value` should be converted to int automatically'
defaultto(:true)
newvalues(:true, :false)
end

Expand Down Expand Up @@ -96,7 +96,7 @@ def validate_value(value)
end

def munge_value(value)
return value if self[:skip_munging] == :true
return value unless self[:autoconvert] == :true
value.each do |k, v|
value[k] = v.to_i if v =~ %r{\A[-+]?[0-9]+\z}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/type/rabbitmq_parameter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
expect(parameter[:value]['myparameter']).to eq(1_800_000)
end

it 'does not munge the value when skip_munging is set to true' do
parameter[:skip_munging] = true
it 'does not convert numeric string to integer when autoconvert is set to false' do
parameter[:autoconvert] = false
value = { 'myparameter' => '1800000' }
parameter[:value] = value
expect(parameter[:value]['myparameter']).to eq('1800000')
Expand Down

0 comments on commit 9e7c94b

Please sign in to comment.