Sha256: 3f48122c9a9ee272c54d6482ff0fa55c154ddf795cde7b8b4067a65b50b058ec

Contents?: true

Size: 706 Bytes

Versions: 6

Compression:

Stored size: 706 Bytes

Contents

module SensitiveDataFilter
  module Middleware
    class Detect
      def initialize(filter)
        @filter = filter
      end

      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

      private

      def run_scan
        SensitiveDataFilter::Scan.new(
          SensitiveDataFilter::Middleware::FILTERABLE.map { |filterable| @filter.send(filterable) }
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensitive_data_filter-0.8.0 lib/sensitive_data_filter/middleware/detect.rb
sensitive_data_filter-0.7.0 lib/sensitive_data_filter/middleware/detect.rb
sensitive_data_filter-0.6.0 lib/sensitive_data_filter/middleware/detect.rb
sensitive_data_filter-0.5.0 lib/sensitive_data_filter/middleware/detect.rb
sensitive_data_filter-0.4.1 lib/sensitive_data_filter/middleware/detect.rb
sensitive_data_filter-0.4.0 lib/sensitive_data_filter/middleware/detect.rb