Permalink
Browse files

allow booleans as values; automatically set type for booleans

  • Loading branch information...
1 parent 39ff26d commit 8ed19a3e02d70c859f0ad43be5ba114dcdf474ab @bleything bleything committed Dec 9, 2011
Showing with 7 additions and 2 deletions.
  1. +6 −1 providers/userdefaults.rb
  2. +1 −1 resources/userdefaults.rb
View
7 providers/userdefaults.rb
@@ -40,7 +40,12 @@ def load_current_resource
cmd = "#{'sudo' if new_resource.sudo} defaults write #{new_resource.domain} "
cmd << "-g " if new_resource.global
cmd << "'#{new_resource.key}' " if new_resource.key
- cmd << "-#{new_resource.type} " if new_resource.type
+
+ if new_resource.value.is_a?(TrueClass) or new_resource.value.is_a?(FalseClass)
+ type = new_resource.type || "bool"
+ end
+
+ cmd << "-#{type} " if type
cmd << "'#{new_resource.value}'"
execute cmd
end
View
2 resources/userdefaults.rb
@@ -22,7 +22,7 @@
attribute :domain, :kind_of => String, :name_attribute => true, :required => true
attribute :global, :kind_of => [TrueClass, FalseClass], :default => false
attribute :key, :kind_of => String, :default => nil
-attribute :value, :kind_of => [Integer,String], :default => nil, :required => true
+attribute :value, :kind_of => [Integer,String,TrueClass,FalseClass], :default => nil, :required => true
attribute :type, :kind_of => String, :default => nil
attribute :sudo, :kind_of => [TrueClass, FalseClass], :default => false
attribute :is_set, :kind_of => [TrueClass, FalseClass], :default => false

0 comments on commit 8ed19a3

Please sign in to comment.