Class: PuppetX::Sensu::BooleanProperty
- Inherits:
-
Puppet::Property
- Object
- Puppet::Property
- PuppetX::Sensu::BooleanProperty
- Defined in:
- lib/puppet_x/sensu/boolean_property.rb
Class Attribute Summary collapse
-
.values_for_false ⇒ Object
readonly
Returns the value of attribute values_for_false.
-
.values_for_true ⇒ Object
readonly
Returns the value of attribute values_for_true.
Instance Method Summary collapse
- #retrieve ⇒ Object
-
#set(value) ⇒ Object
allow the provider to work with real booleans.
-
#unsafe_munge(value) ⇒ Object
normalize to :true and :false true/false (boolean) cannot be used because if the should value of a property is false, puppet will take the purperty as unmanaged and will not even check if it's in sync.
Class Attribute Details
.values_for_false ⇒ Object (readonly)
Returns the value of attribute values_for_false
8 9 10 |
# File 'lib/puppet_x/sensu/boolean_property.rb', line 8 def values_for_false @values_for_false end |
.values_for_true ⇒ Object (readonly)
Returns the value of attribute values_for_true
8 9 10 |
# File 'lib/puppet_x/sensu/boolean_property.rb', line 8 def values_for_true @values_for_true end |
Instance Method Details
#retrieve ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/puppet_x/sensu/boolean_property.rb', line 38 def retrieve s = super case s when true :true when false :false else s end end |
#set(value) ⇒ Object
allow the provider to work with real booleans
34 35 36 |
# File 'lib/puppet_x/sensu/boolean_property.rb', line 34 def set(value) super(value.to_s == 'absent' ? :absent : value == :true) end |
#unsafe_munge(value) ⇒ Object
normalize to :true and :false true/false (boolean) cannot be used because if the should value of a property is false, puppet will take the purperty as unmanaged and will not even check if it's in sync
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet_x/sensu/boolean_property.rb', line 15 def unsafe_munge(value) # downcase strings if value.respond_to? :downcase value = value.downcase end case value when *BooleanProperty.values_for_true :true when *BooleanProperty.values_for_false :false when :absent, 'absent' :absent else fail "expected a boolean value, got #{value.inspect}" end end |