Module: Taro::Rails::ParamParsing

Defined in:
lib/taro/rails/param_parsing.rb

Class Method Summary collapse

Class Method Details

.install(controller_class:, action_name:) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/taro/rails/param_parsing.rb', line 2

def self.install(controller_class:, action_name:)
  return unless Taro.config.parse_params

  key = [controller_class, action_name]
  return if installed[key]

  installed[key] = true

  controller_class.prepend_before_action(only: action_name) do
    declaration = Taro::Rails.declaration_for(self) || raise(
      Taro::InvariantError, "missing Declaration for #{controller_class}##{action_name}"
    )
    @api_params = declaration.params.new(params.to_unsafe_h).coerce_input
  end
end

.installedObject



18
19
20
# File 'lib/taro/rails/param_parsing.rb', line 18

def self.installed
  @installed ||= {}
end