coerce scalars into single-valued arrays

This makes YAML config files look more sane

stdout:
    debug: true

Instead of

stdout:
    debug:
        - true
This commit is contained in:
Stephon Striplin 2012-11-28 11:40:44 -08:00
parent 89c2ee7060
commit 7c74bcce15

View file

@ -302,6 +302,8 @@ module LogStash::Config::Mixin
elsif validator.is_a?(Symbol) elsif validator.is_a?(Symbol)
# TODO(sissel): Factor this out into a coersion method? # TODO(sissel): Factor this out into a coersion method?
# TODO(sissel): Document this stuff. # TODO(sissel): Document this stuff.
value = [*value] # coerce scalar to array if necessary
case validator case validator
when :hash when :hash
if value.size % 2 == 1 if value.size % 2 == 1