Module: ElasticGraph::ProtoIngestion::SchemaDefinition::SchemaElements::ObjectInterfaceAndUnionExtension

Defined in:
elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb

Overview

Extends object/interface/union types with proto field type conversion.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.list_depth_and_base_type(type_ref) ⇒ Array

Returns a type reference's list depth and fully unwrapped base type.

Returns:

  • (Array)


43
44
45
46
47
48
49
50
51
52
53
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb', line 43

def self.list_depth_and_base_type(type_ref)
  list_depth = 0
  current = type_ref.unwrap_non_null

  while current.list?
    list_depth += 1
    current = current.unwrap_list.unwrap_non_null
  end

  [list_depth, current]
end

Instance Method Details

#proto_nameString

Returns this type's name in protobuf schemas.

Returns:

  • (String)


58
59
60
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb', line 58

def proto_name
  name
end

#proto_type_reference(package_name) ⇒ String

Returns the fully qualified name used to reference this message from protobuf fields.

Returns:

  • (String)


65
66
67
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb', line 65

def proto_type_reference(package_name)
  ".#{package_name}.#{proto_name}"
end

#referenced_proto_typesArray

Returns the schema types referenced by this definition.

Returns:

  • (Array)


29
30
31
32
33
34
35
36
37
38
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb', line 29

def referenced_proto_types
  if abstract?
    abstract_type = _ = self
    abstract_type.recursively_resolve_subtypes
  else
    proto_fields.map do |_, field|
      _ = field.type.fully_unwrapped.resolved
    end
  end
end

#to_proto(package_name) ⇒ String

Renders this type's protobuf message definition.

Returns:

  • (String)


22
23
24
# File 'elasticgraph-proto_ingestion/lib/elastic_graph/proto_ingestion/schema_definition/schema_elements/object_interface_and_union_extension.rb', line 22

def to_proto(package_name)
  render_proto_message(proto_name, package_name)
end