Class: Hexx::Storage::Repositories::SQL
- Defined in:
- lib/hexx/storage/repositories/sql.rb
Overview
Container for the ROM :sql repository settings
Instance Attribute Summary collapse
-
#migrations ⇒ String?
The path to migration directory for the current repository.
-
#options ⇒ String?
readonly
The path to migration directory for the current repository.
-
#uri ⇒ String?
readonly
The path to migration directory for the current repository.
Attributes inherited from Base
Instance Method Summary collapse
-
#adapter ⇒ Symbol
Returns the name of the adapter.
-
#conn ⇒ Sequel::Database
Retuns the
Sequelconnection for the repository. -
#initialize(uri:, root: nil, log: nil, **options) ⇒ SQL
constructor
A new instance of SQL.
-
#migrator ⇒ ROM::SQL::Migration::Migrator
Returns the migrator for the repository.
-
#settings ⇒ Array
Returns the array of settings for the ROM repository.
Methods inherited from Base
Constructor Details
#initialize(uri:, root: nil, log: nil, **options) ⇒ SQL
Returns a new instance of SQL.
14 15 16 17 18 |
# File 'lib/hexx/storage/repositories/sql.rb', line 14 def initialize(uri:, root: nil, log: nil, **) @uri = uri = super end |
Instance Attribute Details
#migrations ⇒ String?
The path to migration directory for the current repository
23 24 25 |
# File 'lib/hexx/storage/repositories/sql.rb', line 23 def migrations @migrations end |
#options ⇒ String? (readonly)
The path to migration directory for the current repository
23 24 25 |
# File 'lib/hexx/storage/repositories/sql.rb', line 23 def end |
#uri ⇒ String? (readonly)
The path to migration directory for the current repository
23 24 25 |
# File 'lib/hexx/storage/repositories/sql.rb', line 23 def uri @uri end |
Instance Method Details
#adapter ⇒ Symbol
Returns the name of the adapter
61 62 63 |
# File 'lib/hexx/storage/repositories/sql.rb', line 61 def adapter :sql end |
#conn ⇒ Sequel::Database
Retuns the Sequel connection for the repository
38 39 40 41 42 43 44 |
# File 'lib/hexx/storage/repositories/sql.rb', line 38 def conn @conn ||= begin conn = Sequel.connect uri, ** conn.loggers << logger conn end end |
#migrator ⇒ ROM::SQL::Migration::Migrator
Returns the migrator for the repository
49 50 51 52 53 54 55 56 |
# File 'lib/hexx/storage/repositories/sql.rb', line 49 def migrator @migrator ||= begin rom = ROM::SQL::Migration::Migrator null = Naught.build { |config| config.impersonate rom } klass = migrations ? rom : null klass.new conn, path: migrations end end |
#settings ⇒ Array
Returns the array of settings for the ROM repository
68 69 70 |
# File 'lib/hexx/storage/repositories/sql.rb', line 68 def settings [adapter, (migrations ? [conn, migrator: migrator] : conn)] end |