Class: ActionHandler::Args::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/action_handler/args/params.rb

Instance Method Summary collapse

Constructor Details

#initialize(*names, **nested_params) ⇒ Params

Returns a new instance of Params.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/action_handler/args/params.rb', line 6

def initialize(*names, **nested_params)
  names.each do |name|
    define_singleton_method(name) do |ctrl|
      ctrl.params[name]
    end
  end

  nested_params.each do |name, fields|
    define_singleton_method(name) do |ctrl|
      ctrl.params.require(name).permit(*fields)
    end
  end
end