Class: ActiveFedora::RDF::IndexingService

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/rdf/indexing_service.rb

Overview

Responsible for generating the solr document (via #generate_solr_document) of the given object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, index_config = nil) ⇒ IndexingService

Returns a new instance of IndexingService.

Parameters:

  • obj (#resource, #rdf_subject)

    the object to build an solr document for. Its class must respond to ‘properties’

  • index_config (ActiveFedora::Indexing::Map) (defaults to: nil)

    the configuration to use to map object values to index document values



12
13
14
15
16
17
18
19
# File 'lib/active_fedora/rdf/indexing_service.rb', line 12

def initialize(obj, index_config = nil)
  unless index_config
    Deprecation.warn(self, "initializing ActiveFedora::RDF::IndexingService without an index_config is deprecated and will be removed in ActiveFedora 13.0")
    index_config = obj.class.index_config
  end
  @object = obj
  @index_config = index_config
end

Instance Attribute Details

#index_configObject (readonly)

Returns the value of attribute index_config.



8
9
10
# File 'lib/active_fedora/rdf/indexing_service.rb', line 8

def index_config
  @index_config
end

#objectObject (readonly)

Returns the value of attribute object.



8
9
10
# File 'lib/active_fedora/rdf/indexing_service.rb', line 8

def object
  @object
end

Instance Method Details

#generate_solr_document(prefix_method = nil) {|Hash| ... } ⇒ Hash

Creates a solr document hash for the rdf assertions of the #object

Yields:

  • (Hash)

    yields the solr document

Returns:

  • (Hash)

    the solr document



24
25
26
27
28
# File 'lib/active_fedora/rdf/indexing_service.rb', line 24

def generate_solr_document(prefix_method = nil)
  solr_doc = add_assertions(prefix_method)
  yield(solr_doc) if block_given?
  solr_doc
end