Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumValue
- Inherits:
-
Struct
- Object
- Struct
- ElasticGraph::SchemaDefinition::SchemaElements::EnumValue
- Defined in:
- elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb
Overview
Represents a value of a GraphQL enum type.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Name of the value.
-
#runtime_metadata ⇒ SchemaElements::RuntimeMetadata::Enum::Value
readonly
Runtime metadata.
-
#schema_def_state ⇒ State
readonly
State of the schema.
Attributes included from Mixins::HasDocumentation
Instance Method Summary collapse
-
#duplicate_on(other_enum_type) ⇒ void
Duplicates this enum value on another EnumType.
-
#to_sdl ⇒ String
GraphQL SDL form of the enum value.
-
#update_runtime_metadata(**updates) ⇒ void
Updates the runtime metadata.
Methods included from Mixins::HasDirectives
#directive, #directives, #directives_sdl
Methods included from Mixins::HasDocumentation
#append_to_documentation, #derived_documentation, #documentation, #formatted_documentation
Methods included from Mixins::VerifiesGraphQLName
Instance Attribute Details
#name ⇒ String (readonly)
Returns name of the value.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 25 class EnumValue < Struct.new(:schema_def_state, :name, :runtime_metadata) prepend Mixins::VerifiesGraphQLName include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |v| v.name } # @private def initialize(schema_def_state, name, original_name) = SchemaArtifacts::RuntimeMetadata::Enum::Value.new( sort_field: nil, datastore_value: nil, datastore_abbreviation: nil, alternate_original_name: (original_name if original_name != name) ) super(schema_def_state, name, ) yield self end # @return [String] GraphQL SDL form of the enum value def to_sdl "#{formatted_documentation}#{name}#{directives_sdl(prefix_with: " ")}" end # Duplicates this enum value on another {EnumType}. # # @param other_enum_type [EnumType] enum type to duplicate this value onto # @return [void] def duplicate_on(other_enum_type) other_enum_type.value name do |v| v.documentation doc_comment directives.each { |dir| dir.duplicate_on(v) } v.(**.to_h) end end # Updates the runtime metadata. # # @param [Hash<Symbol, Object>] updates to apply to the runtime metadata # @return [void] def (**updates) self. = .with(**updates) end private :runtime_metadata= end |
#runtime_metadata ⇒ SchemaElements::RuntimeMetadata::Enum::Value (readonly)
Returns runtime metadata.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 25 class EnumValue < Struct.new(:schema_def_state, :name, :runtime_metadata) prepend Mixins::VerifiesGraphQLName include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |v| v.name } # @private def initialize(schema_def_state, name, original_name) = SchemaArtifacts::RuntimeMetadata::Enum::Value.new( sort_field: nil, datastore_value: nil, datastore_abbreviation: nil, alternate_original_name: (original_name if original_name != name) ) super(schema_def_state, name, ) yield self end # @return [String] GraphQL SDL form of the enum value def to_sdl "#{formatted_documentation}#{name}#{directives_sdl(prefix_with: " ")}" end # Duplicates this enum value on another {EnumType}. # # @param other_enum_type [EnumType] enum type to duplicate this value onto # @return [void] def duplicate_on(other_enum_type) other_enum_type.value name do |v| v.documentation doc_comment directives.each { |dir| dir.duplicate_on(v) } v.(**.to_h) end end # Updates the runtime metadata. # # @param [Hash<Symbol, Object>] updates to apply to the runtime metadata # @return [void] def (**updates) self. = .with(**updates) end private :runtime_metadata= end |
#schema_def_state ⇒ State (readonly)
Returns state of the schema.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 25 class EnumValue < Struct.new(:schema_def_state, :name, :runtime_metadata) prepend Mixins::VerifiesGraphQLName include Mixins::HasDocumentation include Mixins::HasDirectives include Mixins::HasReadableToSAndInspect.new { |v| v.name } # @private def initialize(schema_def_state, name, original_name) = SchemaArtifacts::RuntimeMetadata::Enum::Value.new( sort_field: nil, datastore_value: nil, datastore_abbreviation: nil, alternate_original_name: (original_name if original_name != name) ) super(schema_def_state, name, ) yield self end # @return [String] GraphQL SDL form of the enum value def to_sdl "#{formatted_documentation}#{name}#{directives_sdl(prefix_with: " ")}" end # Duplicates this enum value on another {EnumType}. # # @param other_enum_type [EnumType] enum type to duplicate this value onto # @return [void] def duplicate_on(other_enum_type) other_enum_type.value name do |v| v.documentation doc_comment directives.each { |dir| dir.duplicate_on(v) } v.(**.to_h) end end # Updates the runtime metadata. # # @param [Hash<Symbol, Object>] updates to apply to the runtime metadata # @return [void] def (**updates) self. = .with(**updates) end private :runtime_metadata= end |
Instance Method Details
#duplicate_on(other_enum_type) ⇒ void
This method returns an undefined value.
Duplicates this enum value on another ElasticGraph::SchemaDefinition::SchemaElements::EnumType.
53 54 55 56 57 58 59 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 53 def duplicate_on(other_enum_type) other_enum_type.value name do |v| v.documentation doc_comment directives.each { |dir| dir.duplicate_on(v) } v.(**.to_h) end end |
#to_sdl ⇒ String
Returns GraphQL SDL form of the enum value.
45 46 47 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 45 def to_sdl "#{formatted_documentation}#{name}#{directives_sdl(prefix_with: " ")}" end |
#update_runtime_metadata(**updates) ⇒ void
This method returns an undefined value.
Updates the runtime metadata.
65 66 67 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb', line 65 def (**updates) self. = .with(**updates) end |