Permalink
Browse files

add type inference for Integers

  • Loading branch information...
1 parent 7c19dcf commit 268f0aaa0b7899bf6ac8623d9a73062281d38be6 @bleything bleything committed Dec 9, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 providers/userdefaults.rb
@@ -48,9 +48,13 @@ def load_current_resource
cmd << "'#{new_resource.key}'" if new_resource.key
- if new_resource.value.is_a?(TrueClass) or new_resource.value.is_a?(FalseClass)
- type = new_resource.type || "bool"
- end
+ type = new_resource.type
+ type ||= case new_resource.value
+ when TrueClass, FalseClass
+ 'bool'
+ when Integer
+ 'int'
+ end
cmd << "-#{type}" if type
cmd << "'#{new_resource.value}'"

0 comments on commit 268f0aa

Please sign in to comment.