Module: Faraday::Utils
- Defined in:
- lib/github_api2/ext/faraday.rb
Defined Under Namespace
Classes: ParamsHash
Class Method Summary collapse
Class Method Details
.build_nested_query(value, prefix = nil, encoder = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/github_api2/ext/faraday.rb', line 22 def build_nested_query(value, prefix = nil, encoder = nil) case value when Array value.map { |v| build_nested_query(v, "#{prefix}%5B%5D", encoder) }.join("&") when Hash value.map { |k, v| processed_value = encoder ? encoder.escape(k) : escape(k) build_nested_query(v, prefix ? "#{prefix}%5B#{processed_value}%5D" : processed_value, encoder) }.join("&") when NilClass prefix else raise ArgumentError, "value must be a Hash" if prefix.nil? processed_value = encoder ? encoder.escape(value) : escape(value) "#{prefix}=#{processed_value}" end end |