Class: SensitiveDataFilter::Middleware::Detect

Inherits:
Object
  • Object
show all
Defined in:
lib/sensitive_data_filter/middleware/detect.rb

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ Detect

Returns a new instance of Detect.



4
5
6
# File 'lib/sensitive_data_filter/middleware/detect.rb', line 4

def initialize(filter)
  @filter = filter
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/sensitive_data_filter/middleware/detect.rb', line 8

def call
  changeset = nil
  scan = run_scan
  if scan.matches?
    changeset = OpenStruct.new(SensitiveDataFilter::Middleware::FILTERABLE.each_with_object({}) { |filterable, hash|
      hash[filterable.to_s] = SensitiveDataFilter::Mask.mask(@filter.send(filterable))
    })
  end
  [changeset, scan]
end