Sha256: e81d1ae9c5573b34d8ac01aa301c1de5ec0169632727e72cd58c24e30f143203
Contents?: true
Size: 1.31 KB
Versions: 6
Compression:
Stored size: 1.31 KB
Contents
# This module adds a `has_many :collections` association to any models that you mix it into, using the :has_collection_member property # It also provides methods to help you index the information as a facet require 'deprecation' module Hydra::Collections::Collectible extend ActiveSupport::Concern extend Deprecation self.deprecation_horizon = "hydra-collections 4.0" included do has_many :collections, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base" end # Add this method to your solrization logic (ie. in to_solr) in order to populate the 'collection' facet # with the pids of any collections that contain the current object. # @example # def to_solr(solr_doc={}, opts={}) # super(solr_doc, opts) # index_collection_ids(solr_doc) # return solr_doc # end def index_collection_ids(solr_doc={}) # CollectionAssociation#ids_reader loads from solr on each call, so only call it once # see https://github.com/projecthydra/active_fedora/issues/644 ids = collection_ids solr_doc[Solrizer.solr_name(:collection, :facetable)] = ids solr_doc[Solrizer.solr_name(:collection)] = ids solr_doc end def index_collection_pids(solr_doc={}) index_collection_ids(solr_doc) end deprecation_deprecate :index_collection_pids end
Version data entries
6 entries across 6 versions & 1 rubygems