discourse/migrations/lib/common/set_store/simple_set.rb
Gerhard Schlager 53d7a756d6
DEV: Add Migrations::SetStore to work with nested sets of data (#33593)
There are concrete implementations for a simple set, a key-value store,
and nested sets with 2 or 3 keys. The API stays the same for all
implementations and the performances is more or less the same as without
the wrapper (at least with YJIT enabled).
2025-07-24 12:11:41 +02:00

33 lines
458 B
Ruby
Vendored

# frozen_string_literal: true
module Migrations::SetStore
class SimpleSet
include Interface
def initialize
@store = Set.new
end
def add(value)
@store.add(value)
self
end
def add?(value)
!!@store.add?(value)
end
def include?(value)
@store.include?(value)
end
def bulk_add(records)
@store.merge(records)
nil
end
def empty?
@store.empty?
end
end
end