application_handle_info.rb 475 B

12345678910111213141516171819202122232425
  1. module ApplicationHandleInfo
  2. def self.current
  3. Thread.current[:application_handle] || 'unknown'
  4. end
  5. def self.current=(name)
  6. Thread.current[:application_handle] = name
  7. end
  8. def self.postmaster?
  9. return false if current.blank?
  10. current.split('.')[1] == 'postmaster'
  11. end
  12. def self.use(name)
  13. raise ArgumentError, 'requires a block' if !block_given?
  14. orig = current
  15. self.current = name
  16. yield
  17. ensure
  18. self.current = orig
  19. end
  20. end