Class: Exwiw::Adapter::Base
- Inherits:
-
Object
- Object
- Exwiw::Adapter::Base
- Defined in:
- lib/exwiw/adapter.rb
Direct Known Subclasses
MongodbAdapter, Mysql2Adapter, PostgresqlAdapter, Sqlite3Adapter
Instance Attribute Summary collapse
-
#connection_config ⇒ Object
readonly
Returns the value of attribute connection_config.
Class Method Summary collapse
-
.table_config_class ⇒ Object
The config class that this adapter consumes.
Instance Method Summary collapse
-
#build_query(table, dump_target, table_by_name) ⇒ Object
Adapter-specific query object (e.g. Exwiw::QueryAst::Select for SQL).
-
#dumpable?(_config) ⇒ Boolean
Whether the given config produces its own dump output and needs an independent processing pass.
-
#initialize(connection_config, logger) ⇒ Base
constructor
A new instance of Base.
-
#output_extension ⇒ Object
File extension used for dump output (e.g. ‘sql’ for SQL, ‘jsonl’ for MongoDB).
-
#supports_bulk_delete? ⇒ Boolean
Whether this adapter emits delete-NNN-*.sql files.
-
#validate_as_dump_target!(_config) ⇒ Object
Hook for adapter-specific validation when this config is used as the dump_target.
Constructor Details
#initialize(connection_config, logger) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/exwiw/adapter.rb', line 8 def initialize(connection_config, logger) @connection_config = connection_config @logger = logger end |
Instance Attribute Details
#connection_config ⇒ Object (readonly)
Returns the value of attribute connection_config.
6 7 8 |
# File 'lib/exwiw/adapter.rb', line 6 def connection_config @connection_config end |
Class Method Details
.table_config_class ⇒ Object
The config class that this adapter consumes. Runner uses this to decide which Serdes type to load scenario JSON into. SQL adapters share the SQL-shaped TableConfig; non-SQL adapters override.
16 17 18 |
# File 'lib/exwiw/adapter.rb', line 16 def self.table_config_class TableConfig end |
Instance Method Details
#build_query(table, dump_target, table_by_name) ⇒ Object
Returns adapter-specific query object (e.g. Exwiw::QueryAst::Select for SQL).
24 25 26 |
# File 'lib/exwiw/adapter.rb', line 24 def build_query(table, dump_target, table_by_name) raise NotImplementedError end |
#dumpable?(_config) ⇒ Boolean
Whether the given config produces its own dump output and needs an independent processing pass. SQL adapters always do; non-SQL adapters may exclude e.g. embedded subdocument configs.
41 42 43 |
# File 'lib/exwiw/adapter.rb', line 41 def dumpable?(_config) true end |
#output_extension ⇒ Object
File extension used for dump output (e.g. ‘sql’ for SQL, ‘jsonl’ for MongoDB).
29 30 31 |
# File 'lib/exwiw/adapter.rb', line 29 def output_extension 'sql' end |
#supports_bulk_delete? ⇒ Boolean
Whether this adapter emits delete-NNN-*.sql files.
34 35 36 |
# File 'lib/exwiw/adapter.rb', line 34 def supports_bulk_delete? true end |
#validate_as_dump_target!(_config) ⇒ Object
Hook for adapter-specific validation when this config is used as the dump_target. Default: nothing to validate.
47 48 |
# File 'lib/exwiw/adapter.rb', line 47 def validate_as_dump_target!(_config) end |