Module: PermitParams
- Defined in:
- lib/permit_params.rb
Defined Under Namespace
Classes: InvalidParameterError
Instance Method Summary collapse
Instance Method Details
#permitted_params(params, permitted = {}, strong_validation = false, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/permit_params.rb', line 11 def permitted_params(params, permitted = {}, strong_validation = false, = {}) return params if permitted.empty? coerced_params = {} params.each do |key, value| next unless permitted?(permitted: permitted, key: key, value: value) coerced = coerce( param: value, type: permitted[key.to_sym], strong_validation: strong_validation, options: ) coerced_params[key] = coerced unless coerced.nil? end coerced_params end |