blob: 453b3b3fbc9b69beab7a5744812ab01224d65d39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# frozen_string_literal: true
module Ci
module BulkInsertableTags
extend ActiveSupport::Concern
BULK_INSERT_TAG_THREAD_KEY = 'ci_bulk_insert_tags'
class << self
def with_bulk_insert_tags
previous = Thread.current[BULK_INSERT_TAG_THREAD_KEY]
Thread.current[BULK_INSERT_TAG_THREAD_KEY] = true
yield
ensure
Thread.current[BULK_INSERT_TAG_THREAD_KEY] = previous
end
end
# overrides save_tags from acts-as-taggable
def save_tags
super unless Thread.current[BULK_INSERT_TAG_THREAD_KEY]
end
end
end
|