Class: Pal::Operation::Exporter

Inherits:
Object
  • Object
show all
Includes:
Log, Pal::ObjectHelpers
Defined in:
lib/pal/operation/exporter.rb

Overview

Probably a bad name, its really a processor that calls an export impl - w

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Pal::ObjectHelpers

#attributes=, #from_hash, #from_json

Methods included from Log

#log_debug, #log_error, #log_info, #log_warn

Instance Attribute Details

#actionsActions

Returns:



23
24
25
# File 'lib/pal/operation/exporter.rb', line 23

def actions
  @actions
end

#export_typesArray<Pal::Operation::BaseExportHandler> (readonly)



17
18
19
# File 'lib/pal/operation/exporter.rb', line 17

def export_types
  @export_types
end

#propertiesArray<String>

Returns:

  • (Array<String>)


20
21
22
# File 'lib/pal/operation/exporter.rb', line 20

def properties
  @properties
end

Instance Method Details

#perform_export(ctx) ⇒ Array, Hash

Parameters:

Returns:

  • (Array, Hash)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pal/operation/exporter.rb', line 27

def perform_export(ctx)
  log_info("About to extract required data defined in #{ctx.candidates.size} rows")
  extracted_rows, extracted_columns = extract(ctx, @properties)

  if @actions&.processable?
    log_info("Actions have been defined, going off to extract.")
    extracted_rows, extracted_columns = @actions.process(extracted_rows, extracted_columns)
  end

  @export_types.each do |t|
    log_info("Exporting for [#{t.class}] triggered ...")
    t.run_export(extracted_rows, extracted_columns)
    log_info("... export for [#{t.class}] completed")
  end

  [extracted_rows, extracted_columns]
end