Class: DBA::Dump
Constant Summary collapse
- ADAPTERS =
{ 'csv' => :CSV, 'jsonl' => :LDJSON, 'ldjson' => :LDJSON, 'ndjson' => :LDJSON, 'yml' => :YAML, 'yaml' => :YAML }
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
Constructor Details
This class inherits a constructor from DBA::Command
Instance Method Details
#call(table, extension) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dba/dump.rb', line 13 def call(table, extension) self.table_name = table output_path = "#{table_name}.#{extension}" adapter = ADAPTERS.fetch(extension) { raise DBA::Error, 'unsupported file extension' } adapter = DBA.const_get(adapter) rows = database[table_name].count return if rows.zero? adapter.dump(database, table_name, output_path) end |