kibitan/masking

View on GitHub
lib/masking/data_mask_processor/cache.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Masking
  class DataMaskProcessor
    class Cache
      def self.fetch_or_store_if_no_cache(table:, proc:)
        @cache ||= {}

        if @cache.key?(table)
          @cache[table]
        else
          @cache[table] = proc.call
        end
      end

      # onlu for test
      def self.clear
        @cache = {}
      end
    end
  end
end