Class: Pal::Operation::Actions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#log_debug, #log_error, #log_info, #log_warn

Methods included from Pal::ObjectHelpers

#attributes=, #from_hash, #from_json

Instance Attribute Details

#group_byArray<String>

Returns:

  • (Array<String>)


13
14
15
# File 'lib/pal/operation/actions.rb', line 13

def group_by
  @group_by
end

#projectionProjection

Returns:



19
20
21
# File 'lib/pal/operation/actions.rb', line 19

def projection
  @projection
end

#sort_byString

Returns:

  • (String)


16
17
18
# File 'lib/pal/operation/actions.rb', line 16

def sort_by
  @sort_by
end

Instance Method Details

#process(rows, column_headers) ⇒ Array

Returns rows, column_headers.

Parameters:

  • rows (Array)
  • column_headers (Hash)

Returns:

  • (Array)

    rows, column_headers



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pal/operation/actions.rb', line 34

def process(rows, column_headers)
  grouped = perform_group_by(rows, column_headers)

  return [rows, column_headers] unless @projection&.processable?

  log_info("Performing projection by [#{@projection.type}].")
  rows, column_headers = perform_projection(grouped, column_headers)
  rows, column_headers = perform_sort_by(rows, column_headers)

  [rows, column_headers]
end

#processable?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/pal/operation/actions.rb', line 26

def processable?
  # Do better in the future
  !@group_by.nil?
end