Module: LoggerWare::Filter
- Included in:
- Collector
- Defined in:
- lib/logger_ware/filter.rb
Constant Summary collapse
- REPLACE_WITH =
'[FILTERED]'
Instance Method Summary collapse
- #filter(params, filters, replace_with = REPLACE_WITH) ⇒ Object
- #filter?(param, filters) ⇒ Boolean
- #match?(param, f) ⇒ Boolean
Instance Method Details
#filter(params, filters, replace_with = REPLACE_WITH) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/logger_ware/filter.rb', line 18 def filter(params, filters, replace_with = REPLACE_WITH) params.each_with_object({}) do |(k,v), res| v = filter(v, filters, replace_with) if v.is_a?(Hash) res[k] = filter?(k, filters) ? replace_with : v end end |
#filter?(param, filters) ⇒ Boolean
13 14 15 16 |
# File 'lib/logger_ware/filter.rb', line 13 def filter?(param, filters) filters.each { |f| return true if match?(param, f) } false end |
#match?(param, f) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/logger_ware/filter.rb', line 5 def match?(param, f) if f.is_a?(Regexp) !!(param.to_s =~ f) else param.to_s == f.to_s end end |