Class: Valkyrie::Sequel::MetadataAdapter
- Inherits:
-
Object
- Object
- Valkyrie::Sequel::MetadataAdapter
- Defined in:
- lib/valkyrie/sequel/metadata_adapter.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(connection:) ⇒ MetadataAdapter
constructor
A new instance of MetadataAdapter.
- #perform_migrations! ⇒ Object
- #persister ⇒ Object
- #query_service ⇒ Object
- #reset_database! ⇒ Object
- #resource_factory ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize(connection:) ⇒ MetadataAdapter
Returns a new instance of MetadataAdapter.
8 9 10 11 12 13 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 8 def initialize(connection:) @connection = connection.tap do |conn| conn.extension(:pg_json) conn.extension(:pg_streaming) end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 7 def connection @connection end |
Instance Method Details
#id ⇒ Object
27 28 29 30 31 32 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 27 def id @id ||= begin to_hash = "sequel://#{host}:#{port}:#{database}" Valkyrie::ID.new(Digest::MD5.hexdigest(to_hash)) end end |
#perform_migrations! ⇒ Object
34 35 36 37 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 34 def perform_migrations! Sequel.extension :migration Sequel::Migrator.run(connection, "#{__dir__}/../../../db/migrations") end |
#persister ⇒ Object
15 16 17 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 15 def persister @persister ||= Persister.new(adapter: self) end |
#query_service ⇒ Object
19 20 21 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 19 def query_service @query_service ||= QueryService.new(adapter: self) end |
#reset_database! ⇒ Object
39 40 41 42 43 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 39 def reset_database! Sequel.extension :migration Sequel::Migrator.run(connection, "#{__dir__}/../../../db/migrations", target: 0) perform_migrations! end |
#resource_factory ⇒ Object
23 24 25 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 23 def resource_factory @resource_factory ||= ResourceFactory.new(adapter: self) end |
#resources ⇒ Object
45 46 47 |
# File 'lib/valkyrie/sequel/metadata_adapter.rb', line 45 def resources connection.from(:orm_resources) end |