Class: DataTaster::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/data_taster/collection.rb,
sig/data_taster.rbs

Overview

Ingests the processed yml file and returns either an empty hash (for cases that are skippable) or a hash that contains: select: (whatever is configured to go in the SELECT .. WHERE clause) sanitize: the columns and values that need custom sanitization

Instance Method Summary collapse

Constructor Details

#initialize(table_name) ⇒ Collection

Returns a new instance of Collection.

Parameters:

  • table_name (String)


12
13
14
15
# File 'lib/data_taster/collection.rb', line 12

def initialize(table_name)
  @table_name = table_name
  @ingredients = DataTaster.confection[table_name]
end

Instance Method Details

#assembleHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


17
18
19
20
21
22
23
24
25
26
# File 'lib/data_taster/collection.rb', line 17

def assemble
  DataTaster.logger.info("#{table_name}...")

  if skippable?
    DataTaster.logger.info("configured to skip both schema and data")
    {}
  else
    { select: selection, sanitize: sanitization }
  end
end

#export_select_sqlString

Returns:

  • (String)


28
29
30
31
32
33
# File 'lib/data_taster/collection.rb', line 28

def export_select_sql
  <<-SQL.squish
    SELECT * FROM #{source_db}.#{table_name}
    WHERE #{where_clause}
  SQL
end