Sha256: ca6e7a0ebca38e61515f53ed29f1669fcdbea86389391c69b9592fad7f226a24

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require_relative 'all_jobs_shared'

class SharedTransforms < Remi::Job
  sub_transform :id_prefixer, prefix: 'DEFAULT' do
    # Declare the required data subjects and data subject fields
    source :st_source, [:st_source_id]
    target :st_target, [:st_prefixed_id]

    # Do anything that is allowed in a transform with the provided data subjects and fields
    Remi::SourceToTargetMap.apply(st_source.df, st_target.df) do
      map source(:st_source_id) .target(:st_prefixed_id)
        .transform(Remi::Transform::Prefix.new(params[:prefix]))
    end
  end
end

class SubTransformExampleJob < Remi::Job
  param(:job_prefix) { nil }

  source :my_source do
    fields({ :id => {} })
  end

  target :my_target do
    fields(
      {
        :id => {},
        :default_id => {}
      }
    )
  end

  transform :main do
    my_target.df = my_source.df.dup
    sub_trans_params = job.params[:job_prefix].nil? ? {} : { prefix: job.params[:job_prefix] }

    import SharedTransforms.new.id_prefixer, sub_trans_params do
      map_source_fields :my_source, :st_source, { :id => :st_source_id }
      map_target_fields :st_target, :my_target, { :st_prefixed_id => :default_id }
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
remi-0.3.3 jobs/sub_transform_example_job.rb
remi-0.3.2 jobs/sub_transform_example_job.rb
remi-0.3.1 jobs/sub_transform_example_job.rb
remi-0.3.0 jobs/sub_transform_example_job.rb