Sha256: 9b9633895b30226a4114a3a3baaa70412c3dc49f8e89b0be497a2edf7c1c26fd

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 Bytes

Contents

module Remi
  class Job
    class SubJob
      def initialize(context=nil, name: 'UNDEFINED SubJob', **kargs, &block)
        @context = context
        @name = name
        @block = block
      end

      attr_accessor :context, :name

      def dsl_return
        result = Dsl.dsl_return(self, @context, &@block)
        raise ArgumentError, "SubJob DSL must return a Remi::Job" unless result.is_a? Job
        result
      end

      def sub_job
        @sub_job ||= dsl_return
      end

      def fields(data_subject)
        sub_job.send(data_subject).dsl_eval.fields
      end

      def execute
        execute! unless @executed
      end

      def execute!
        result = sub_job.execute
        @executed = true
        result
      end

      def execute_transforms
        sub_job.execute(:transforms)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
remi-0.3.3 lib/remi/job/sub_job.rb
remi-0.3.2 lib/remi/job/sub_job.rb
remi-0.3.1 lib/remi/job/sub_job.rb