Sha256: ddc9e11523b5dd2b94175d330cf409c1c6516d39eb2a765482320a55b54f6185

Contents?: true

Size: 690 Bytes

Versions: 3

Compression:

Stored size: 690 Bytes

Contents

module InstDataShipper
  class BasicDumper < Dumper
    def self.perform_dump(destinations:, schema:, &block)
      raise "Schema must be a constantizable string" unless schema.is_a?(String)

      dumper = new(destinations)
      dumper.instance_variable_set(:@schema_pointer, schema)
      dumper.instance_variable_set(:@body_block, block)
      dumper.begin_dump

      dumper.tracker
    end

    hook :initialize_dump_batch do |context|
      context[:schema_pointer] = @schema_pointer
    end

    def enqueue_tasks
      instance_exec(&@body_block)
    end

    def schema
      pointer = @schema_pointer || batch_context[:schema_pointer]
      pointer.constantize
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
inst_data_shipper-0.2.2 lib/inst_data_shipper/basic_dumper.rb
inst_data_shipper-0.2.1 lib/inst_data_shipper/basic_dumper.rb
inst_data_shipper-0.2.0 lib/inst_data_shipper/basic_dumper.rb