Class: Exwiw::Adapter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/exwiw/adapter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_configObject (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_classObject

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).

Returns:

  • (Object)

    adapter-specific query object (e.g. Exwiw::QueryAst::Select for SQL)

Raises:

  • (NotImplementedError)


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.

Returns:

  • (Boolean)


41
42
43
# File 'lib/exwiw/adapter.rb', line 41

def dumpable?(_config)
  true
end

#output_extensionObject

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.

Returns:

  • (Boolean)


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