Module: ParamsCleaner
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/params_cleaner.rb,
lib/params_cleaner/version.rb,
lib/params_cleaner/whitelist.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Whitelist
Constant Summary
collapse
- VERSION =
"0.4.3"
Instance Method Summary
collapse
Instance Method Details
#_action_whitelists ⇒ Object
22
23
24
|
# File 'lib/params_cleaner.rb', line 22
def _action_whitelists
self.class._action_whitelists
end
|
#_applicable_whitelists ⇒ Object
26
27
28
|
# File 'lib/params_cleaner.rb', line 26
def _applicable_whitelists
[_action_whitelists[:_all_], _action_whitelists[_current_action_name]].compact
end
|
#_current_action_name ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/params_cleaner.rb', line 30
def _current_action_name
if respond_to?(:action_name)
action_name.to_sym
else
nil
end
end
|
#clean_params ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/params_cleaner.rb', line 12
def clean_params
sanitized_params = _applicable_whitelists.map do |whitelist|
whitelist.sanitize(params)
end
sanitized_params.inject(HashWithIndifferentAccess.new) do |new_params, sanitized|
new_params.deep_merge(sanitized)
end
end
|