Module: ActionBlocks::SummaryFieldAggregationFunctions

Included in:
SummaryFieldBuilder
Defined in:
lib/action_blocks/builders/summary_field_aggregation_functions.rb

Instance Method Summary collapse

Instance Method Details

#concat(field, delimiter) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/action_blocks/builders/summary_field_aggregation_functions.rb', line 15

def concat(field, delimiter)
  mk = @parent_reference.related_model_key.clone
  mk["model-"]=''
  field_key = "field-#{mk}-#{field}"
  puts field_key
  field_builder = ActionBlocks.find(field_key)

  return {
    path: field_builder.select_requirements[:path],
    function: ->(*args) { string_agg(delimiter, *args) }
  }
end

#countObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/action_blocks/builders/summary_field_aggregation_functions.rb', line 3

def count
  # mk = @parent_reference.related_model_key.clone
  # mk["model-"]=''
  # field_key = "field-#{mk}-#{id}"
  # field_builder = ActionBlocks.find(field_key)

  return {
    path: [:id],
    function: ->(*args) { count(*args) }\
  }
end

#every(field, predicate, value) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/action_blocks/builders/summary_field_aggregation_functions.rb', line 28

def every(field, predicate, value)
  mk = @parent_reference.related_model_key.clone
  mk["model-"]=''
  field_key = "field-#{mk}-#{field}"
  puts field_key
  field_builder = ActionBlocks.find(field_key)

  return {
  path: field_builder.select_requirements[:path],
  function: ->(*args) { every(predicate, value, *args) }
  }
end