Module: Respect::Rails::HeadersSimplifier
- Included in:
- RequestSchema, ResponseSchema
- Defined in:
- lib/respect/rails/headers_simplifier.rb
Instance Method Summary (collapse)
-
- (Object) simplify_headers(headers)
Copy the given
headers
hash table but get rid of the complex type at the same time.
Instance Method Details
- (Object) simplify_headers(headers)
Copy the given headers
hash table but get rid of the
complex type at the same time.
This is useful if you plan to serialize headers
and want to
get rid of complex type which may raise errors when serializing.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/respect/rails/headers_simplifier.rb', line 9 def simplify_headers(headers) case headers when String, Numeric, TrueClass, FalseClass, Symbol, Mime::Type headers when Array result = [] headers.each do |x| v = simplify_headers(x) result << v if v end result when Hash result = {} headers.each do |k, v| new_v = simplify_headers(v) result[k] = new_v if new_v end result end end |