2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2019-03-13 23:51:22 +00:00
|
|
|
module Mixin
|
|
|
|
module HasBackends
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2020-08-28 14:07:30 +00:00
|
|
|
class_attribute :backends do
|
2019-03-13 23:51:22 +00:00
|
|
|
Set.new
|
|
|
|
end
|
|
|
|
|
2020-08-19 15:24:19 +00:00
|
|
|
self_path = ActiveSupport::Dependencies.search_for_file name.underscore
|
|
|
|
backends_path = self_path.delete_suffix File.extname(self_path)
|
|
|
|
|
|
|
|
Mixin::RequiredSubPaths.eager_load_recursive backends_path
|
|
|
|
|
|
|
|
backends = "#{name}::Backend".constantize.descendants
|
|
|
|
|
|
|
|
self.backends = Set.new(backends)
|
2019-03-13 23:51:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|