2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2013-06-19 12:04:09 +00:00
|
|
|
module EventBuffer
|
|
|
|
|
2016-04-13 23:50:22 +00:00
|
|
|
def self.list(key)
|
|
|
|
if !Thread.current[:event_buffer]
|
|
|
|
Thread.current[:event_buffer] = {}
|
|
|
|
end
|
|
|
|
Thread.current[:event_buffer][key] || []
|
2013-06-19 12:04:09 +00:00
|
|
|
end
|
|
|
|
|
2016-04-13 23:50:22 +00:00
|
|
|
def self.add(key, item)
|
2013-06-19 12:04:09 +00:00
|
|
|
if !Thread.current[:event_buffer]
|
2016-04-13 23:50:22 +00:00
|
|
|
Thread.current[:event_buffer] = {}
|
|
|
|
end
|
|
|
|
if !Thread.current[:event_buffer][key]
|
|
|
|
Thread.current[:event_buffer][key] = []
|
2013-06-19 12:04:09 +00:00
|
|
|
end
|
2016-04-13 23:50:22 +00:00
|
|
|
Thread.current[:event_buffer][key].push item
|
2013-06-19 12:04:09 +00:00
|
|
|
end
|
|
|
|
|
2016-04-13 23:50:22 +00:00
|
|
|
def self.reset(key)
|
|
|
|
return if !Thread.current[:event_buffer]
|
|
|
|
return if !Thread.current[:event_buffer][key]
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-04-13 23:50:22 +00:00
|
|
|
Thread.current[:event_buffer][key] = []
|
2013-06-19 12:04:09 +00:00
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|