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: ) ⇒ 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



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

initialize_with(:model, :builder, 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>)


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

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

  add_method("#{name}_id") { params.require(:id) }
  add_method("#{name}_params") do
    params.require(method_name)
          .permit(*allowed_attributes)
  end
end