Class: Glib::JsonUi::ActionBuilder::Http::AbstractHttp

Inherits:
Action show all
Defined in:
app/helpers/glib/json_ui/action_builder/http.rb

Direct Known Subclasses

Delete, Get, Patch, Post

Instance Attribute Summary

Attributes inherited from JsonUiElement

#json, #page

Instance Method Summary collapse

Methods inherited from JsonUiElement

#initialize, #props

Constructor Details

This class inherits a constructor from Glib::JsonUi::JsonUiElement

Instance Method Details

#flatten_nested_params(form_data, key, value) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'app/helpers/glib/json_ui/action_builder/http.rb', line 15

def flatten_nested_params(form_data, key, value)
  if value.is_a?(Hash)
    value.each do |nested_key, nested_value|
      flatten_nested_params(form_data, "#{key}[#{nested_key}]", nested_value)
    end
  else
    form_data[key] = value
  end
end

#formData(hash) ⇒ Object



7
8
9
10
11
12
13
# File 'app/helpers/glib/json_ui/action_builder/http.rb', line 7

def formData(hash)
  form_data = {}
  hash.each do |key, value|
    flatten_nested_params(form_data, key, value)
  end
  json.formData form_data
end