lib/chronicle/etl/extractors/extractor.rb in chronicle-etl-0.5.5 vs lib/chronicle/etl/extractors/extractor.rb in chronicle-etl-0.6.1
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'chronicle/etl'
module Chronicle
module ETL
# Abstract class representing an Extractor for an ETL job
@@ -19,11 +21,11 @@
# Options for configuring this Extractor
def initialize(options = {})
apply_options(options)
end
- # Hook called before #extract. Useful for gathering data, initailizing proxies, etc
+ # Hook called before #extract. Useful for gathering data, initializing proxies, etc
def prepare; end
# An optional method to calculate how many records there are to extract. Used primarily for
# building the progress bar
def results_count; end
@@ -31,10 +33,21 @@
# Entrypoint for this Extractor. Called by a Runner. Expects a series of records to be yielded
def extract
raise NotImplementedError
end
- private
+ protected
+
+ def build_extraction(data:, meta: nil, source: nil, type: nil, strategy: nil)
+ Extraction.new(
+ extractor: self.class,
+ data: data,
+ meta: meta,
+ source: source || self.class.connector_registration.source,
+ type: type || self.class.connector_registration.type,
+ strategy: strategy || self.class.connector_registration.strategy
+ )
+ end
# TODO: reimplemenet this
# def handle_continuation
# return unless @config.continuation