class Humidifier::Props::MapProp

Attributes

subprop[R]

Public Class Methods

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

Public Instance Methods

pretty_print(q) click to toggle source
# File lib/humidifier/props.rb, line 150
def pretty_print(q)
  q.group do
    q.text("(#{name}=map")
    q.nest(2) do
      q.breakable
      q.pp(subprop)
    end
    q.breakable("")
    q.text(")")
  end
end
to_cf(map) click to toggle source
# File lib/humidifier/props.rb, line 162
def to_cf(map)
  cf_value =
    if map.respond_to?(:to_cf)
      map.to_cf
    else
      map.to_h do |subkey, subvalue|
        [subkey, subprop.to_cf(subvalue).last]
      end
    end

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

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