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
-
.list_depth_and_base_type(type_ref) ⇒ Array
Returns a type reference's list depth and fully unwrapped base type.
Instance Method Summary collapse
-
#proto_name ⇒ String
Returns this type's name in protobuf schemas.
-
#proto_type_reference(package_name) ⇒ String
Returns the fully qualified name used to reference this message from protobuf fields.
-
#referenced_proto_types ⇒ Array
Returns the schema types referenced by this definition.
-
#to_proto(package_name) ⇒ String
Renders this type's protobuf message definition.
Class Method Details
.list_depth_and_base_type(type_ref) ⇒ Array
Returns a type reference's list depth and fully unwrapped base type.
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_name ⇒ String
Returns this type's name in protobuf schemas.
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.
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_types ⇒ Array
Returns the schema types referenced by this definition.
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.
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) (proto_name, package_name) end |