Class: Lenjador::Preprocessors::Blacklist
- Inherits:
-
Object
- Object
- Lenjador::Preprocessors::Blacklist
- Defined in:
- lib/lenjador/preprocessors/blacklist.rb
Defined Under Namespace
Classes: UnsupportedActionException
Constant Summary collapse
- DEFAULT_ACTION =
'prune'- MASK_SYMBOL =
'*'- MASKED_VALUE =
MASK_SYMBOL * 5
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Blacklist
constructor
A new instance of Blacklist.
- #process(data) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Blacklist
Returns a new instance of Blacklist.
13 14 15 16 17 18 19 20 |
# File 'lib/lenjador/preprocessors/blacklist.rb', line 13 def initialize(config = {}) @fields_to_process = config[:fields].inject({}) do |mem, field| key = field.delete(:key) = {action: DEFAULT_ACTION}.merge(field) validate_action_supported([:action]) mem.merge(key => ) end end |
Instance Method Details
#process(data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lenjador/preprocessors/blacklist.rb', line 22 def process(data) case data when Hash data.inject({}) do |mem, (key, val)| if (field = @fields_to_process[key.to_s]) send(action_method(field[:action]), mem, key, val) else mem.merge(key => process(val)) end end when Array data.inject([]) do |mem, val| mem + [process(val)] end else data end end |