Module: Curate::Indexer

Defined in:
lib/curate/indexer.rb,
lib/curate/indexer/index.rb,
lib/curate/indexer/railtie.rb,
lib/curate/indexer/version.rb,
lib/curate/indexer/adapters.rb,
lib/curate/indexer/documents.rb,
lib/curate/indexer/exceptions.rb,
lib/curate/indexer/preservation.rb,
lib/curate/indexer/configuration.rb,
lib/curate/indexer/storage_module.rb,
lib/curate/indexer/repository_reindexer.rb,
lib/curate/indexer/relationship_reindexer.rb,
lib/curate/indexer/adapters/abstract_adapter.rb,
lib/curate/indexer/adapters/in_memory_adapter.rb

Overview

Establishing namespace

Defined Under Namespace

Modules: Adapters, Documents, Exceptions, StorageModule Classes: Railtie

Constant Summary collapse

DEFAULT_TIME_TO_LIVE =

This assumes a rather deep graph

15
VERSION =
"0.2.0".freeze

Class Method Summary collapse

Class Method Details

.adapterObject



48
49
50
# File 'lib/curate/indexer.rb', line 48

def self.adapter
  configuration.adapter
end

.configurationObject

Contains the Curate::Indexer configuration information that is referenceable from wit

See Also:

  • Configuration


43
44
45
# File 'lib/curate/indexer.rb', line 43

def self.configuration
  @configuration ||= Configuration.new
end

.configure(&block) ⇒ Object

See Also:



55
56
57
58
59
60
61
62
# File 'lib/curate/indexer.rb', line 55

def self.configure(&block)
  @configuration_block = block
  configure!
  # The Rails load sequence means that some of the configured Targets may
  # not be loaded; As such I am not calling configure! instead relying on
  # Curate::Indexer::Railtie to handle the configure! call
  configure! unless defined?(Rails)
end

.configure!Object



65
66
67
68
69
# File 'lib/curate/indexer.rb', line 65

def self.configure!
  return false unless @configuration_block.respond_to?(:call)
  @configuration_block.call(configuration)
  @configuration_block = nil
end

.reindex_all!(time_to_live = DEFAULT_TIME_TO_LIVE) ⇒ Boolean

Responsible for reindexing the entire preservation layer.

Parameters:

  • time_to_live (Integer) (defaults to: DEFAULT_TIME_TO_LIVE)
    • there to guard against cyclical graphs

Returns:

  • (Boolean)
    • It was successful

Raises:

  • Curate::Exceptions::CycleDetectionError - A potential cycle was detected



36
37
38
39
# File 'lib/curate/indexer.rb', line 36

def self.reindex_all!(time_to_live = DEFAULT_TIME_TO_LIVE)
  RepositoryReindexer.call(time_to_live: time_to_live, pid_reindexer: method(:reindex_relationships), adapter: configuration.adapter)
  true
end

.reindex_relationships(pid, time_to_live = DEFAULT_TIME_TO_LIVE) ⇒ Boolean Also known as: reindex

Responsible for reindexing the associated document for the given :pid and the descendants of that :pid. In a perfect world we could reindex the pid as well; But that is for another test.

Parameters:

  • pid (String)
    • The permanent identifier of the object that will be reindexed along with its children.

  • time_to_live (Integer) (defaults to: DEFAULT_TIME_TO_LIVE)
    • there to guard against cyclical graphs

Returns:

  • (Boolean)
    • It was successful

Raises:

  • Curate::Exceptions::CycleDetectionError - A potential cycle was detected



20
21
22
23
# File 'lib/curate/indexer.rb', line 20

def self.reindex_relationships(pid, time_to_live = DEFAULT_TIME_TO_LIVE)
  RelationshipReindexer.call(pid: pid, time_to_live: time_to_live, adapter: configuration.adapter)
  true
end