Class: Valkyrie::Persistence::Postgres::MetadataAdapter

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

Overview

Metadata Adapter for Postgres Adapter.

This adapter uses ActiveRecord to persist resources in a JSON-B column named `metadata`. This requires setting up a database.

Instance Method Summary collapse

Instance Method Details

#idValkyrie::ID

Construct a Valkyrie ID object using an MD5 hash generated from the database URL

Returns:


32
33
34
35
36
37
# File 'lib/valkyrie/persistence/postgres/metadata_adapter.rb', line 32

def id
  @id ||= begin
    to_hash = "#{resource_factory.orm_class.connection_config['host']}:#{resource_factory.orm_class.connection_config['database']}"
    Valkyrie::ID.new(Digest::MD5.hexdigest(to_hash))
  end
end

#persisterClass

Returns Persister.

Returns:


13
14
15
# File 'lib/valkyrie/persistence/postgres/metadata_adapter.rb', line 13

def persister
  Valkyrie::Persistence::Postgres::Persister.new(adapter: self)
end

#query_serviceClass

Returns QueryService.

Returns:


18
19
20
21
22
23
# File 'lib/valkyrie/persistence/postgres/metadata_adapter.rb', line 18

def query_service
  @query_service ||= Valkyrie::Persistence::Postgres::QueryService.new(
    resource_factory: resource_factory,
    adapter: self
  )
end

#resource_factoryClass

Returns ResourceFactory.

Returns:


26
27
28
# File 'lib/valkyrie/persistence/postgres/metadata_adapter.rb', line 26

def resource_factory
  @resource_factory ||= Valkyrie::Persistence::Postgres::ResourceFactory.new(adapter: self)
end