Method: Satis::Forms::Builder#flatten_hash

Defined in:
lib/satis/forms/builder.rb

#flatten_hash(hash) ⇒ Object



469
470
471
472
473
474
475
476
477
478
479
# File 'lib/satis/forms/builder.rb', line 469

def flatten_hash(hash)
  hash.each_with_object({}) do |(k, v), h|
    if v.is_a? Hash
      flatten_hash(v).map do |h_k, h_v|
        h[:"#{k}_#{h_k}"] = h_v
      end
    else
      h[k] = v
    end
  end
end