Class: Azeroth::ParamsBuilder Private

Inherits:
Sinclair::Model
  • Object
show all
Defined in:
lib/azeroth/params_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class responsible for adding params handling methods to a controller

Author:

  • Darthjee

Instance Method Summary collapse

Constructor Details

#initialize(model: , builder: , options: ) ⇒ ParamsBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • model (Model) (defaults to: )

    Resource interface

  • builder (Sinclair) (defaults to: )

    Methods builder

  • options (Azeroth::Options) (defaults to: )

    options



17
# File 'lib/azeroth/params_builder.rb', line 17

initialize_with(:model, :builder, :options, writter: false)

Instance Method Details

#appendArray<Sinclair::MethodDefinition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Append the params methods to be built

Returns:

  • (Array<Sinclair::MethodDefinition>)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/azeroth/params_builder.rb', line 22

def append
  method_name = name
  allowed_attributes = permitted_attributes.map(&:to_sym)

  param_key = options.param_key
  add_method("#{name}_id") { params.require(param_key) }
  add_method("#{name}_params") do
    params.require(method_name)
          .permit(*allowed_attributes)
  end
end