Class: Valkyrie::IndexingAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/indexing_adapter.rb

Overview

IndexingAdapter is the primary DataMapper object for indexing.

Used to register and locate adapters, for individual
indexing backends (such as solr, elasticsearch, etc)

Class Method Summary collapse

Class Method Details

.find(short_name) ⇒ Object

Find an adapter by its short name.

Parameters:

  • short_name (Symbol)

Returns:

  • adapter

Raises:

  • RuntimeError when the given short_name is not found amongst the registered adapters


22
23
24
25
26
# File 'lib/valkyrie/indexing_adapter.rb', line 22

def find(short_name)
  symbolized_key = short_name.to_sym
  return adapters[symbolized_key] if adapters.key?(symbolized_key)
  raise KeyError, "Unable to find unregistered adapter `#{short_name}'"
end

.register(adapter, short_name) ⇒ Object

Register an adapter by a short name. Registering an adapter by a short name makes the adapter easier to find and reference.

Parameters:

  • adapter

    Adapter to register.

  • short_name (Symbol)

    Name to register it under.


14
15
16
# File 'lib/valkyrie/indexing_adapter.rb', line 14

def register(adapter, short_name)
  adapters[short_name.to_sym] = adapter
end