has_backends.rb 568 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Mixin
  3. module HasBackends
  4. extend ActiveSupport::Concern
  5. included do
  6. class_attribute :backends do
  7. Set.new
  8. end
  9. self_path = ActiveSupport::Dependencies.search_for_file name.underscore
  10. backends_path = self_path.delete_suffix File.extname(self_path)
  11. Mixin::RequiredSubPaths.eager_load_recursive name, backends_path
  12. backends = "#{name}::Backend".constantize.descendants
  13. self.backends = Set.new(backends)
  14. end
  15. end
  16. end