2016-08-20 19:29:22 +00:00
|
|
|
module ApplicationHandleInfo
|
|
|
|
def self.current
|
|
|
|
Thread.current[:application_handle] || 'unknown'
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.current=(name)
|
|
|
|
Thread.current[:application_handle] = name
|
|
|
|
end
|
2017-11-23 08:09:44 +00:00
|
|
|
|
|
|
|
def self.postmaster?
|
|
|
|
return false if current.blank?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-11-23 08:09:44 +00:00
|
|
|
current.split('.')[1] == 'postmaster'
|
|
|
|
end
|
2019-04-10 17:14:34 +00:00
|
|
|
|
|
|
|
def self.use(name)
|
|
|
|
raise ArgumentError, 'requires a block' if !block_given?
|
|
|
|
|
|
|
|
orig = current
|
|
|
|
self.current = name
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
self.current = orig
|
|
|
|
end
|
2016-08-20 19:29:22 +00:00
|
|
|
end
|