Module: Ethon::Easy::Queryable

Defined in:
lib/canvas-api.rb

Instance Method Summary collapse

Instance Method Details

#recursively_generate_pairs(h, prefix, pairs) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/canvas-api.rb', line 299

def recursively_generate_pairs(h, prefix, pairs)
  case h
  when Hash
    h.each_pair do |k,v|
      key = prefix.nil? ? k : "#{prefix}[#{k}]"
      pairs_for(v, key, pairs)
    end
  when Canvas::PairArray
    h.each do |k, v|
      key = prefix.nil? ? k : "#{prefix}[#{k}]"
      pairs_for(v, key, pairs)
    end
  when Array
    h.each_with_index do |v, i|
      key = "#{prefix}[#{i}]"
      pairs_for(v, key, pairs)
    end
  end
end