Module: Hyrax::Indexers
- Defined in:
- app/indexers/hyrax/indexers.rb,
app/indexers/hyrax/indexers/file_set_indexer.rb,
app/indexers/hyrax/indexers/resource_indexer.rb,
app/indexers/hyrax/indexers/pcdm_object_indexer.rb,
app/indexers/hyrax/indexers/pcdm_collection_indexer.rb,
app/indexers/hyrax/indexers/administrative_set_indexer.rb
Defined Under Namespace
Classes: AdministrativeSetIndexer, FileSetIndexer, PcdmCollectionIndexer, PcdmObjectIndexer, ResourceIndexer
Class Method Summary collapse
-
.PcdmObjectIndexer(work_class) ⇒ Object
Provides a model‐specific subclass for
Hyrax::Indexers::PcdmObjectIndexer
. -
.ResourceIndexer(model_class) ⇒ Object
Returns the indexer class associated with a given model.
Class Method Details
.PcdmObjectIndexer(work_class) ⇒ Object
Provides a model‐specific subclass for Hyrax::Indexers::PcdmObjectIndexer
.
The base Hyrax engine could get on without this, but it’s useful for downstream applications and reflects what we do for forms.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/indexers/hyrax/indexers.rb', line 11 def self.PcdmObjectIndexer(work_class) # rubocop:disable Naming/MethodName Class.new(Hyrax::Indexers::PcdmObjectIndexer) do @model_class = work_class class << self attr_reader :model_class ## # @return [String] def inspect return "Hyrax::Indexers::PcdmObjectIndexer(#{model_class})" if name.blank? super end end end end |
.ResourceIndexer(model_class) ⇒ Object
Returns the indexer class associated with a given model.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/indexers/hyrax/indexers.rb', line 32 def self.ResourceIndexer(model_class) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Naming/MethodName @resource_indexers ||= {}.compare_by_identity @resource_indexers[model_class] ||= # +#respond_to?+ needs to be used here, not +#try+, because Dry::Types # overrides the latter?? if model_class.respond_to?(:pcdm_collection?) && model_class.pcdm_collection? if model_class <= Hyrax::AdministrativeSet Hyrax.config.administrative_set_indexer else Hyrax.config.pcdm_collection_indexer end elsif model_class.respond_to?(:pcdm_object?) && model_class.pcdm_object? if model_class.respond_to?(:file_set?) && model_class.file_set? Hyrax.config.file_set_indexer else Hyrax.config.pcdm_object_indexer_builder.call(model_class) end else Hyrax::Indexers::ResourceIndexer end end |