Class: TTY::Logger::DataFilter
- Inherits:
-
Object
- Object
- TTY::Logger::DataFilter
- Defined in:
- lib/tty/logger/data_filter.rb
Constant Summary collapse
- FILTERED =
"[FILTERED]"
- DOT =
"."
Instance Attribute Summary collapse
-
#compiled_filters ⇒ Object
readonly
Returns the value of attribute compiled_filters.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#mask ⇒ Object
readonly
Returns the value of attribute mask.
Instance Method Summary collapse
-
#filter(obj) ⇒ Object
Filter object for keys matching provided filters.
-
#initialize(filters = [], mask: nil) ⇒ DataFilter
constructor
private
Create a data filter instance with filters.
Constructor Details
#initialize(filters = [], mask: nil) ⇒ DataFilter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a data filter instance with filters.
20 21 22 23 24 |
# File 'lib/tty/logger/data_filter.rb', line 20 def initialize(filters = [], mask: nil) @mask = mask || FILTERED @filters = filters @compiled_filters = compile(filters) end |
Instance Attribute Details
#compiled_filters ⇒ Object (readonly)
Returns the value of attribute compiled_filters.
9 10 11 |
# File 'lib/tty/logger/data_filter.rb', line 9 def compiled_filters @compiled_filters end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
9 10 11 |
# File 'lib/tty/logger/data_filter.rb', line 9 def filters @filters end |
#mask ⇒ Object (readonly)
Returns the value of attribute mask.
9 10 11 |
# File 'lib/tty/logger/data_filter.rb', line 9 def mask @mask end |
Instance Method Details
#filter(obj) ⇒ Object
Filter object for keys matching provided filters.
37 38 39 40 41 42 43 |
# File 'lib/tty/logger/data_filter.rb', line 37 def filter(obj) return obj if filters.empty? obj.each_with_object({}) do |(k, v), acc| acc[k] = filter_val(k, v) end end |