trabajo-afectivo/lib/event_buffer.rb

30 lines
695 B
Ruby
Raw Normal View History

# 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]
2016-04-13 23:50:22 +00:00
Thread.current[:event_buffer][key] = []
2013-06-19 12:04:09 +00:00
end
end