Module: Swirl::Helpers::Expander
- Included in:
- AWS
- Defined in:
- lib/swirl/helpers.rb
Class Method Summary collapse
Class Method Details
.expand(request) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/swirl/helpers.rb', line 44 def (request) request.inject({}) do |exp, (key, value)| next(exp) if !key.is_a?(String) case value when Array key = "#{key}.#" if key !~ /#/ value.each_with_index do |val, n| # We must use n+1 because some api's do not allow a 0 index exp[key.gsub("#", (n+1).to_s)] = val end when Range exp["From#{key}"] = value.min exp["To#{key}"] = value.max else exp[key] = value end exp end end |