Class: GraphQL::Language::Nodes::EnumTypeExtension

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, directives: NO_CHILDREN, values: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ EnumTypeExtension

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



2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
# File 'lib/graphql/language/nodes.rb', line 2284

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

Instance Attribute Details

#directives ⇒ Object (readonly)

: Array



2257
2258
2259
# File 'lib/graphql/language/nodes.rb', line 2257

def directives
  @directives
end

#name ⇒ Object (readonly)

: String



2250
2251
2252
# File 'lib/graphql/language/nodes.rb', line 2250

def name
  @name
end

#values ⇒ Object (readonly)

: Array



2259
2260
2261
# File 'lib/graphql/language/nodes.rb', line 2259

def values
  @values
end

Class Method Details

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



2295
2296
2297
# File 'lib/graphql/language/nodes.rb', line 2295

def self.from_a(filename, line, col, name, directives, values, comment: nil)
  self.new(filename: filename, line: line, col: col, name: name, directives: directives, values: values)
end

Instance Method Details

#children ⇒ Object



2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
# File 'lib/graphql/language/nodes.rb', line 2269

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



2299
2300
2301
2302
2303
2304
2305
2306
2307
# File 'lib/graphql/language/nodes.rb', line 2299

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

#marshal_load(values) ⇒ Object



2309
2310
2311
# File 'lib/graphql/language/nodes.rb', line 2309

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

#merge_directive(**node_opts) ⇒ Object



2261
2262
2263
# File 'lib/graphql/language/nodes.rb', line 2261

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

#merge_value(**node_opts) ⇒ Object



2265
2266
2267
# File 'lib/graphql/language/nodes.rb', line 2265

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

#scalars ⇒ Object



2252
2253
2254
# File 'lib/graphql/language/nodes.rb', line 2252

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

#visit_method ⇒ Object



2245
2246
2247
# File 'lib/graphql/language/nodes.rb', line 2245

def visit_method
  :on_enum_type_extension
end