Class: Humidifier::Props::JsonProp
- Defined in:
- lib/humidifier/props/json_prop.rb
Overview
A Json property
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#key, #name, #spec, #substructs
Instance Method Summary collapse
-
#convert(value) ⇒ Object
converts the value through ‘Hash` unless it is valid.
-
#valid?(value) ⇒ Boolean
true if the value is whitelisted, a Hash, or an Array.
Methods inherited from Base
#documentation, #initialize, #required?, #to_cf, #update_type, #whitelisted_value?
Constructor Details
This class inherits a constructor from Humidifier::Props::Base
Instance Method Details
#convert(value) ⇒ Object
converts the value through ‘Hash` unless it is valid
8 9 10 11 12 13 14 15 |
# File 'lib/humidifier/props/json_prop.rb', line 8 def convert(value) if valid?(value) || !convertable?(value) value else puts "WARNING: Property #{name} should be a Hash" Hash[value] end end |
#valid?(value) ⇒ Boolean
true if the value is whitelisted, a Hash, or an Array
18 19 20 |
# File 'lib/humidifier/props/json_prop.rb', line 18 def valid?(value) whitelisted_value?(value) || value.is_a?(Hash) end |