activitypub-academy/app/lib/activity_logger.rb

23 lines
372 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class ActivityLogger
2023-01-13 03:48:04 +09:00
@@loggers = Hash.new { |hash, key| hash[key] = [] }
def self.register(id, sse)
2023-01-13 03:48:04 +09:00
@@loggers[id] << sse
end
2023-01-13 03:48:04 +09:00
def self.unregister(id, sse)
@@loggers[id].delete(sse)
end
def self.log(id, event)
2023-01-13 03:48:04 +09:00
@@loggers[id].each { |logger| logger.write event }
end
def self.reset
@@loggers.clear
end
end