Module: ElasticGraph::GraphQL::Aggregation::FieldPathEncoder

Defined in:
lib/elastic_graph/graphql/aggregation/field_path_encoder.rb

Constant Summary collapse

DELIMITER =

Embedded fields need to be specified with dot separators.

"."

Class Method Summary collapse

Class Method Details

.decode(field_path) ⇒ Object

Takes a field path (e.g., “amountMoney.amount”) and returns the field name parts ([“amountMoney”, “amount”]).



35
36
37
# File 'lib/elastic_graph/graphql/aggregation/field_path_encoder.rb', line 35

def self.decode(field_path)
  field_path.split(DELIMITER)
end

.encode(field_names) ⇒ Object

Takes a list of field names (e.g., [“amountMoney”, “amount”]) and returns a single field name path string (e.g., “amountMoney.amount”).



20
21
22
23
24
25
26
# File 'lib/elastic_graph/graphql/aggregation/field_path_encoder.rb', line 20

def self.encode(field_names)
  field_names.each do |str|
    verify_delimiters(str)
  end

  join(field_names)
end

.join(encoded_paths) ⇒ Object

Joins together a list of encoded paths.



29
30
31
# File 'lib/elastic_graph/graphql/aggregation/field_path_encoder.rb', line 29

def self.join(encoded_paths)
  encoded_paths.join(DELIMITER)
end