class Humidifier::Props::MapProp

Attributes

subprop[R]

Public Class Methods

new(key, spec = {}, substructs = {}) click to toggle source
Calls superclass method Humidifier::Props::Prop::new
# File lib/humidifier/props.rb, line 109
def initialize(key, spec = {}, substructs = {})
  super(key, spec)
  @subprop = Props.singular_from(key, spec, substructs)
end

Public Instance Methods

to_cf(map) click to toggle source
# File lib/humidifier/props.rb, line 114
def to_cf(map)
  cf_value =
    if map.respond_to?(:to_cf)
      map.to_cf
    else
      map.map do |subkey, subvalue|
        [subkey, subprop.to_cf(subvalue).last]
      end.to_h
    end

  [key, cf_value]
end
valid?(map) click to toggle source
Calls superclass method Humidifier::Props::Prop#valid?
# File lib/humidifier/props.rb, line 127
def valid?(map)
  return true if super(map)

  map.is_a?(Hash) && map.values.all? { |value| subprop.valid?(value) }
end