Sha256: 6b2a183d0315bd59206e3af6270fc1ad43199c9adbffccfb8cd9f95cdbbdca01

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

module Humidifier
  module Props
    # A property that is contained in a list
    class ListProp < Base
      attr_reader :subprop

      # CFN stack syntax
      def to_cf(list)
        [key, list.map { |value| subprop.to_cf(value).last }]
      end

      # Valid if the value is whitelisted or every value in the list is valid on the subprop
      def valid?(list)
        whitelisted_value?(list) || (list.is_a?(Enumerable) && list.all? { |value| subprop.valid?(value) })
      end

      private

      # Finds the subprop that's specified in the spec
      def after_initialize(substructs)
        @subprop = Props.singular_from(key, spec, substructs)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
humidifier-1.0.5 lib/humidifier/props/list_prop.rb
humidifier-1.0.4 lib/humidifier/props/list_prop.rb