Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

allow booleans as values; automatically set type for booleans

  • Loading branch information...
commit 8ed19a3e02d70c859f0ad43be5ba114dcdf474ab 1 parent 39ff26d
Ben Bleything authored December 09, 2011
7  providers/userdefaults.rb
@@ -40,7 +40,12 @@ def load_current_resource
40 40
     cmd = "#{'sudo' if new_resource.sudo} defaults write #{new_resource.domain} "
41 41
     cmd << "-g " if new_resource.global
42 42
     cmd << "'#{new_resource.key}' " if new_resource.key
43  
-    cmd << "-#{new_resource.type} " if new_resource.type
  43
+
  44
+    if new_resource.value.is_a?(TrueClass) or new_resource.value.is_a?(FalseClass)
  45
+      type = new_resource.type || "bool"
  46
+    end
  47
+
  48
+    cmd << "-#{type} " if type
44 49
     cmd << "'#{new_resource.value}'"
45 50
     execute cmd
46 51
   end
2  resources/userdefaults.rb
@@ -22,7 +22,7 @@
22 22
 attribute :domain, :kind_of => String, :name_attribute => true, :required => true
23 23
 attribute :global, :kind_of => [TrueClass, FalseClass], :default => false
24 24
 attribute :key, :kind_of => String, :default => nil
25  
-attribute :value, :kind_of => [Integer,String], :default => nil, :required => true
  25
+attribute :value, :kind_of => [Integer,String,TrueClass,FalseClass], :default => nil, :required => true
26 26
 attribute :type, :kind_of => String, :default => nil
27 27
 attribute :sudo, :kind_of => [TrueClass, FalseClass], :default => false
28 28
 attribute :is_set, :kind_of => [TrueClass, FalseClass], :default => false

0 notes on commit 8ed19a3

Please sign in to comment.
Something went wrong with that request. Please try again.