Class: ActionParamsPermitter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_params_permitter/base.rb

Overview

Entry for creating custom permitters

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/action_params_permitter/base.rb', line 6

def initialize(&block)
  builder.instance_eval(&block)
end

Instance Method Details

#hash_for_permittingObject

Provides hash that must be passed to ‘permit` method.

Returns: generated hash of permitter definition



16
17
18
# File 'lib/action_params_permitter/base.rb', line 16

def hash_for_permitting
  builder.state
end

#permit(params) ⇒ Object

Calls permitting income params using permitter definition

Parameters: params - instance of ActionController::Parameters

Returns: hash of permitted params



29
30
31
# File 'lib/action_params_permitter/base.rb', line 29

def permit(params)
  PermitProcessor.new(params, builder).call
end