Class: DumpCleaner::Cleanup::Uniqueness::CaseInsensitiveCache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/dump_cleaner/cleanup/uniqueness.rb

Instance Method Summary collapse

Constructor Details

#initializeCaseInsensitiveCache

Returns a new instance of CaseInsensitiveCache.



45
46
47
# File 'lib/dump_cleaner/cleanup/uniqueness.rb', line 45

def initialize
  clear
end

Instance Method Details

#clearObject



49
50
51
# File 'lib/dump_cleaner/cleanup/uniqueness.rb', line 49

def clear
  @data = {}
end

#known?(type:, value:) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
# File 'lib/dump_cleaner/cleanup/uniqueness.rb', line 53

def known?(type:, value:)
  return false unless @data.key?(type)

  @data[type].include?(value.downcase)
end

#push(type:, value:) ⇒ Object



59
60
61
62
# File 'lib/dump_cleaner/cleanup/uniqueness.rb', line 59

def push(type:, value:)
  @data[type] ||= Set.new
  @data[type].add(value.downcase)
end