Class: GraphQL::EnumType::EnumValue

Inherits:
Object
  • Object
show all
Includes:
Define::InstanceDefinable
Defined in:
lib/graphql/enum_type.rb

Overview

A value within an GraphQL::EnumType

Created with the value helper

Constant Summary collapse

ATTRIBUTES =
[:name, :description, :deprecation_reason, :value]

Instance Method Summary collapse

Methods included from Define::InstanceDefinable

#define, #initialize_copy, #metadata, #redefine

Instance Method Details

#name=(new_name) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/graphql/enum_type.rb', line 142

def name=(new_name)
  # Validate that the name is correct
  unless new_name =~ /^[_a-zA-Z][_a-zA-Z0-9]*$/
    raise(
      GraphQL::EnumType::InvalidEnumNameError,
      "Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but '#{new_name}' does not"
    )
  end

  @name = new_name
end