Class: Valkyrie::MetadataAdapter

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

Overview

MetadataAdapter is the primary DataMapper object for metadata persistence.

Used to register and locate adapters, persisters, and query services for individual
metadata storage backends (such as fedora, postgres, etc)

Class Method Summary collapse

Class Method Details

.find(short_name) ⇒ #persister, #query_service

Find an adapter by its short name.

Parameters:

  • short_name (Symbol)

Returns:

  • (#persister, #query_service)

Raises:

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



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

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

.find_persister_for(short_name) ⇒ Object

Find the persister registered under the given short-name

Parameters:

  • short_name (Symbol)

Returns:

  • (Object)

    an object that behaves like “a Valkyrie::Persister”

See Also:

  • GEM_ROOT/lib/valkyrie/specs/shared_specs/persister.rb

Since:

  • 0.1.0



35
36
37
# File 'lib/valkyrie/metadata_adapter.rb', line 35

def find_persister_for(short_name)
  find(short_name).persister
end

.find_query_service_for(short_name) ⇒ Object

Find the query service registered under the given short-name

Parameters:

  • short_name (Symbol)

Returns:

  • (Object)

    an object that behaves like “a Valkyrie query provider”

See Also:

  • GEM_ROOT/lib/valkyrie/specs/shared_specs/queries.rb

Since:

  • 0.1.0



46
47
48
# File 'lib/valkyrie/metadata_adapter.rb', line 46

def find_query_service_for(short_name)
  find(short_name).query_service
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 (#persister, #query_service)

    Adapter to register.

  • short_name (Symbol)

    Name to register it under.



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

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