event_buffer.rb 309 B

123456789101112131415161718
  1. module EventBuffer
  2. def self.list
  3. Thread.current[:event_buffer] || []
  4. end
  5. def self.add(item)
  6. if !Thread.current[:event_buffer]
  7. Thread.current[:event_buffer] = []
  8. end
  9. Thread.current[:event_buffer].push item
  10. end
  11. def self.reset
  12. Thread.current[:event_buffer] = []
  13. end
  14. end