module ExternalMigration::Transformer
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)
@abstract
Public Instance Methods
begin(schema_from, schema_to)
click to toggle source
called on start of migration
# 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)
click to toggle source
Ignore a field starts with ignore(.*): assumes length fields or separator @return [Hash] row without ignores @example
schema: columns: digit: format: N length: 10 ignore_not_need_this__really__so_i_ll_not_touch_this: length: 10000
# File lib/external_migration/migration.rb, line 60 def transform_ignore_fields(row) row.reject! { |key,value| key.to_s.start_with?("ignore") } end