Class: Airbrake::Utils::ParamsCleaner
- Inherits:
-
Object
- Object
- Airbrake::Utils::ParamsCleaner
- Defined in:
- lib/airbrake/utils/params_cleaner.rb
Instance Attribute Summary collapse
-
#blacklist_filters ⇒ Object
writeonly
Sets the attribute blacklist_filters.
-
#cgi_data ⇒ Object
readonly
Returns the value of attribute cgi_data.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#session_data ⇒ Object
readonly
Returns the value of attribute session_data.
-
#to_clean ⇒ Object
writeonly
Sets the attribute to_clean.
-
#whitelist_filters ⇒ Object
writeonly
Sets the attribute whitelist_filters.
Instance Method Summary collapse
-
#clean ⇒ Object
Public: Takes the params to_clean passed in an initializer and filters them out by filters passed.
-
#initialize(opts = {}) ⇒ ParamsCleaner
constructor
Public: Initialize a new Airbrake::Utils::ParamsCleaner.
Constructor Details
#initialize(opts = {}) ⇒ ParamsCleaner
Public: Initialize a new Airbrake::Utils::ParamsCleaner
opts - The Hash options that contain filters and params (default: {}):
:blacklist_filters - The Array of param keys that should be filtered
:whitelist_filters - The Array of param keys that shouldn't be filtered
:to_clean - The Hash of unfiltered params
:blacklist_filters take precedence over the :whitelist_filters
14 15 16 17 18 19 20 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 14 def initialize(opts = {}) @blacklist_filters = (opts[:blacklist_filters] || []).flatten @blacklist_filters.map!{|f| f.is_a?(Symbol) ? f.to_s : f } @whitelist_filters = (opts[:whitelist_filters] || []).flatten @whitelist_filters.map!{|f| f.is_a?(Symbol) ? f.to_s : f } @to_clean = opts[:to_clean] end |
Instance Attribute Details
#blacklist_filters=(value) ⇒ Object (writeonly)
Sets the attribute blacklist_filters
4 5 6 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 4 def blacklist_filters=(value) @blacklist_filters = value end |
#cgi_data ⇒ Object (readonly)
Returns the value of attribute cgi_data.
5 6 7 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 5 def cgi_data @cgi_data end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
5 6 7 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 5 def parameters @parameters end |
#session_data ⇒ Object (readonly)
Returns the value of attribute session_data.
5 6 7 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 5 def session_data @session_data end |
#to_clean=(value) ⇒ Object (writeonly)
Sets the attribute to_clean
4 5 6 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 4 def to_clean=(value) @to_clean = value end |
#whitelist_filters=(value) ⇒ Object (writeonly)
Sets the attribute whitelist_filters
4 5 6 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 4 def whitelist_filters=(value) @whitelist_filters = value end |
Instance Method Details
#clean ⇒ Object
Public: Takes the params to_clean passed in an initializer
and filters them out by filters passed.
Also normalizes unserializable data.
Returns self, so that :parameters, :cgi_data, :session_data could be extracted
29 30 31 32 33 34 35 36 |
# File 'lib/airbrake/utils/params_cleaner.rb', line 29 def clean clean_parameters clean_session_data clean_cgi_data clean_rack_request_data self end |