Sha256: 724097e10079ff62a105189808abaedc7bea004fd96817f5c1aeddd1583988e4

Contents?: true

Size: 473 Bytes

Versions: 10

Compression:

Stored size: 473 Bytes

Contents

# frozen_string_literal: true

require 'json'
require 'ostruct'

module Params
  module FormForObjectHelper
    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
actionset-0.11.0 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.10.0 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.9.2 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.9.1 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.8.2 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.8.1 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.8.0 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.7.0 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.6.0 lib/action_set/helpers/params/form_for_object_helper.rb
actionset-0.5.4 lib/action_set/helpers/params/form_for_object_helper.rb