Class: ElasticGraph::SchemaDefinition::SchemaElements::EnumValue

Inherits:
Struct
  • Object
show all
Includes:
Mixins::HasDirectives, Mixins::HasDocumentation, Mixins::VerifiesGraphQLName
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

SortOrderEnumValue

Instance Attribute Summary collapse

Attributes included from Mixins::HasDocumentation

#doc_comment

Instance Method Summary collapse

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

verify_name!

Instance Attribute Details

#nameString (readonly)

Returns name of the value.

Returns:

  • (String)

    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_metadataSchemaElements::RuntimeMetadata::Enum::Value (readonly)

Returns runtime metadata.

Returns:

  • (SchemaElements::RuntimeMetadata::Enum::Value)

    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_stateState (readonly)

Returns state of the schema.

Returns:

  • (State)

    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.

Parameters:

  • other_enum_type (EnumType)

    enum type to duplicate this value onto



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_sdlString

Returns GraphQL SDL form of the enum value.

Returns:

  • (String)

    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.

Parameters:

  • updates (Hash<Symbol, Object>)

    to apply to 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