Skip to content

Instantly share code, notes, and snippets.

@flyingzumwalt
Last active December 16, 2015 14:59
Show Gist options
  • Save flyingzumwalt/5452720 to your computer and use it in GitHub Desktop.
Save flyingzumwalt/5452720 to your computer and use it in GitHub Desktop.

Callback: ActiveFedora::Base.solrization_logic

Example of usage

class GenericFile
    after_solrize << :index_collection_pids

    def index_collection_pids(solr_doc={})
         collection_pids = self.collections.map {|c| c.pid}
         solr_doc[Solrizer.solr_name(:collection, :searchable)] = collection_pids
    end
end

Example of implementation

module ActiveFedora::Indexing
  ...
  define_callbacks :solrize, :update_index
  
  def to_solr(solr_doc={})
      run_callbacks :save do
         ...
      end
  end
end

module Hydra::Collections::Collectible

   def self.included(base)
       base.after_solrize << :index_collection_pids
   end

    def index_collection_pids(solr_doc={})
         collection_pids = self.collections.map {|c| c.pid}
         solr_doc[Solrizer.solr_name(:collection, :searchable)] = collection_pids
    end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment