Module: Params::FormForObjectHelper

Included in:
ActionSet::Helpers::HelperMethods
Defined in:
lib/action_set/helpers/params/form_for_object_helper.rb

Instance Method Summary collapse

Instance Method Details

#form_for_object_from_param(param, defaults = {}) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/action_set/helpers/params/form_for_object_helper.rb', line 8

def form_for_object_from_param(param, defaults = {})
  form_for_params = current_params.fetch(param, {})
  form_for_requirements = { model_name: { param_key: param } }
  form_for_hash = defaults.merge(form_for_params).merge(form_for_requirements)

  JSON.parse(form_for_hash.to_json,
             object_class: OpenStruct)
end