Class: ActiveElement::PreRenderProcessors::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/active_element/pre_render_processors/json.rb

Overview

Selects fields from ‘__json_fields` param created by `Components::JsonField` and parses each field’s JSON data back into request params to allow for transparent JSON data receipt. All params are permitted and converted to a Hash to allow them to be modified before converting back to ActionController::Params to avoid disrupting the Rails request flow.

Instance Method Summary collapse

Constructor Details

#initialize(controller:) ⇒ Json

Returns a new instance of Json.



10
11
12
# File 'lib/active_element/pre_render_processors/json.rb', line 10

def initialize(controller:)
  @controller = controller
end

Instance Method Details

#processObject



14
15
16
17
18
19
20
# File 'lib/active_element/pre_render_processors/json.rb', line 14

def process
  return if json_fields.blank?

  process_json_fields
  delete_meta_params
  rebuild_action_controller_parameters
end