module PactBroker::Config::RuntimeConfigurationCoercionMethods

Private Instance Methods

value_to_integer_array(value, property_name) click to toggle source
# File lib/pact_broker/config/runtime_configuration_coercion_methods.rb, line 26
def value_to_integer_array value, property_name
  if value.is_a?(String)
    PactBroker::Config::SpaceDelimitedIntegerList.parse(value)
  elsif value.is_a?(Array)
    value.collect { |v| v.to_i }
  elsif value.is_a?(Integer)
    [value]
  elsif value
    raise ConfigurationError.new("Pact Broker configuration property `#{property_name}` must be a space delimited String or an Array of Integers. Got: #{value.inspect}")
  end
end
value_to_string_array(value, property_name) click to toggle source
# File lib/pact_broker/config/runtime_configuration_coercion_methods.rb, line 7
def value_to_string_array value, property_name
  if value.is_a?(String)
    PactBroker::Config::SpaceDelimitedStringList.parse(value)
  elsif value.is_a?(Array)
    # parse structured values to possible regexp
    [*value].flat_map do | val |
      if val.is_a?(String)
        PactBroker::Config::SpaceDelimitedStringList.parse(val)
      else
        [val]
      end
    end
  elsif value
    raise ConfigurationError.new("Pact Broker configuration property `#{property_name}` must be a space delimited String or an Array. Got: #{value.inspect}")
  end
end