Class: Hanami::Logger::Formatter::HashFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/logger.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Filtering logic

Since:

  • 1.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filters = []) ⇒ HashFilter

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.

Returns a new instance of HashFilter.

Since:

  • 1.1.0



239
240
241
# File 'lib/hanami/logger.rb', line 239

def initialize(filters = [])
  @filters = filters
end

Instance Attribute Details

#filtersObject (readonly)

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.

Since:

  • 1.1.0



235
236
237
# File 'lib/hanami/logger.rb', line 235

def filters
  @filters
end

Instance Method Details

#filter(hash) ⇒ Object

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.

Since:

  • 1.1.0



245
246
247
248
249
250
251
252
# File 'lib/hanami/logger.rb', line 245

def filter(hash)
  _filtered_keys(hash).each do |key|
    *keys, last = _actual_keys(hash, key.split('.'))
    keys.inject(hash, :fetch)[last] = '[FILTERED]'
  end

  hash
end