Module: ExternalMigration::Transformer Abstract

Included in:
GroupedFieldFixedSpelling
Defined in:
lib/external_migration/migration.rb,
lib/external_migration/transformer/grouped_field_fixed_spelling.rb

Overview

This module is abstract.

Module for Data Transformation When passing schema file or struct, the data between datasources needs a transformations.

# called on start of transaction
def begin_transaction(schema_from, schema_to)

# definily obrigatory to define this method!<br>
# Transform from data row to destinate data row 
# @result
#   - true means continue with your job
#   - false stop job now!
#   - :ignore ignore this chunk
def transform(row)

# called on ending migration
def end(schema_from, schema_to)

# called on ending transaction
def end_transaction(schema_from, schema_to)

def after_row_saved(row, object)

Defined Under Namespace

Classes: GroupedFieldFixedSpelling

Instance Method Summary collapse

Instance Method Details

#begin(schema_from, schema_to) ⇒ Object

called on start of migration



44
45
46
47
# File 'lib/external_migration/migration.rb', line 44

def begin(schema_from, schema_to)
  @schema_from = schema_from
  @schema_to = schema_to
end

#transform_ignore_fields(row) ⇒ Hash

Ignore a field starts with ignore(.*): assumes length fields or separator

Examples:

schema:
  columns:
    digit:
      format: N
      length: 10
    ignore_not_need_this__really__so_i_ll_not_touch_this:
      length: 10000

Returns:

  • (Hash)

    row without ignores



60
61
62
# File 'lib/external_migration/migration.rb', line 60

def transform_ignore_fields(row)
  row.reject! { |key,value| key.to_s.start_with?("ignore") }
end