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
|