Class: GraphQL::Language::Nodes::EnumTypeDefinition

Inherits:
AbstractNode
  • Object
show all
Defined in:
lib/graphql/language/nodes.rb

Constant Summary

Constants inherited from AbstractNode

AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #to_query_string

Constructor Details

#initialize(name: nil, description: nil, comment: nil, directives: NO_CHILDREN, values: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) ⇒ EnumTypeDefinition

: (?name: untyped, ?description: untyped, ?comment: untyped, ?directives: Array, ?values: Array, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped, ?definition_pos: Integer?) -> void



2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
# File 'lib/graphql/language/nodes.rb', line 2204

def initialize(name: nil, description: nil, comment: nil, directives: NO_CHILDREN, values: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil)
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
  @name = name
  @description = description && -description
  @comment = comment
  @directives = directives.freeze
  @values = values.freeze
  @definition_pos = definition_pos
end

Instance Attribute Details

#comment ⇒ Object (readonly)

: String?



2168
2169
2170
# File 'lib/graphql/language/nodes.rb', line 2168

def comment
  @comment
end

#description ⇒ Object (readonly)

: String?



2166
2167
2168
# File 'lib/graphql/language/nodes.rb', line 2166

def description
  @description
end

#directives ⇒ Object (readonly)

: Array



2177
2178
2179
# File 'lib/graphql/language/nodes.rb', line 2177

def directives
  @directives
end

#name ⇒ Object (readonly)

: String



2170
2171
2172
# File 'lib/graphql/language/nodes.rb', line 2170

def name
  @name
end

#values ⇒ Object (readonly)

: Array



2179
2180
2181
# File 'lib/graphql/language/nodes.rb', line 2179

def values
  @values
end

Class Method Details

.from_a(filename, line, col, name, description, directives, values, comment: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



2218
2219
2220
# File 'lib/graphql/language/nodes.rb', line 2218

def self.from_a(filename, line, col, name, description, directives, values, comment: nil) # rubocop:disable Metrics/ParameterLists
  self.new(filename: filename, line: line, col: col, name: name, description: description, comment: comment, directives: directives, values: values)
end

Instance Method Details

#children ⇒ Object



2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
# File 'lib/graphql/language/nodes.rb', line 2189

def children
  @children ||= begin
    if !@directives.empty? || !@values.empty?
      new_children = []
      new_children.concat(@directives)
      new_children.concat(@values)
      new_children.freeze
      new_children
    else
      NO_CHILDREN
    end
  end
end

#marshal_dump ⇒ Object



2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
# File 'lib/graphql/language/nodes.rb', line 2222

def marshal_dump
  [
    line, col, # use methods here to force them to be calculated
    @filename,
    @name,
    @description,
    @directives,
    @values,
  ]
end

#marshal_load(values) ⇒ Object



2233
2234
2235
# File 'lib/graphql/language/nodes.rb', line 2233

def marshal_load(values)
  @line, @col, @filename, @name, @description, @directives, @values = values
end

#merge_directive(**node_opts) ⇒ Object



2181
2182
2183
# File 'lib/graphql/language/nodes.rb', line 2181

def merge_directive(**node_opts)
  merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)])
end

#merge_value(**node_opts) ⇒ Object



2185
2186
2187
# File 'lib/graphql/language/nodes.rb', line 2185

def merge_value(**node_opts)
  merge(values: values + [GraphQL::Language::Nodes::EnumValueDefinition.new(**node_opts)])
end

#scalars ⇒ Object



2172
2173
2174
# File 'lib/graphql/language/nodes.rb', line 2172

def scalars
  @scalars ||= [@name].freeze
end

#visit_method ⇒ Object



2161
2162
2163
# File 'lib/graphql/language/nodes.rb', line 2161

def visit_method
  :on_enum_type_definition
end