Sha256: 31ce9da7e86e2f9b660a0657ad2ad240f90821ab51aa6d5ae19cff1d2665c634

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 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
      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

23 entries across 23 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.1.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.1.0.beta1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.rc3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.rc2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.rc1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.0.5 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.beta5 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.beta4 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.beta3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.beta2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-2.0.0.beta1 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.0.4 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.0.3 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.0.2 app/search_builders/hyrax/abstract_type_relation.rb
hyrax-1.0.1 app/search_builders/hyrax/abstract_type_relation.rb