Method: EasyPost::InternalUtilities.form_encode_params
- Defined in:
- lib/easypost/internal_utilities.rb
.form_encode_params(hash, parent_keys = [], parent_dict = {}) ⇒ Object
Form-encode a multi-layer dictionary to a one-layer dictionary.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easypost/internal_utilities.rb', line 12 def self.form_encode_params(hash, parent_keys = [], parent_dict = {}) result = parent_dict or {} keys = parent_keys or [] hash.each do |key, value| if value.instance_of?(Hash) keys << key result = form_encode_params(value, keys, result) else dict_key = build_dict_key(keys + [key]) result[dict_key] = value end end result end |