Sha256: c11d59cdb1b4aed293650947587e637cbe2a255ebe1a542101c5f14d77fe3925

Contents?: true

Size: 1.12 KB

Versions: 35

Compression:

Stored size: 1.12 KB

Contents

module Hyrax
  class AbstractTypeRelation < ActiveFedora::Relation
    def initialize(opts = {})
      super(DummyModel, opts)
    end

    def allowable_types
      raise NotImplementedException, "Implement allowable_types in a subclass"
    end

    def equivalent_class?(klass)
      allowable_types.include?(klass)
    end

    def search_model_clause
      clauses = allowable_types.map do |k|
        ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: k.to_s)
      end
      # empty array returns nil, AF finder method handles it properly, see hyrax issue #2844
      clauses.size <= 1 ? clauses.first : "(#{clauses.join(' OR ')})"
    end

    class DummyModel
      def self.primary_concern
        Hyrax.config.curation_concerns.first
      end

      def self.delegated_attributes
        primary_concern.delegated_attributes
      end

      def self.solr_query_handler
        primary_concern.solr_query_handler
      end

      def self.default_sort_params
        primary_concern.default_sort_params
      end

      def self.id_to_uri(*args)
        primary_concern.id_to_uri(*args)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.5 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.4 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.9.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.8.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.7.2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.7.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.7.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.6.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-3.0.0.pre.rc1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-3.0.0.pre.beta3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.5.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.5.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-3.0.0.pre.beta2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.4.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-3.0.0.pre.beta1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.4.0 app/search_builders/hyrax/abstract_type_relation.rb