Class: RuboCop::GraphQL::Argument

Inherits:
Object
  • Object
show all
Extended by:
NodePattern::Macros
Defined in:
lib/rubocop/graphql/argument.rb,
lib/rubocop/graphql/argument/block.rb,
lib/rubocop/graphql/argument/kwargs.rb

Defined Under Namespace

Classes: Block, Kwargs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Argument

Returns a new instance of Argument.



25
26
27
# File 'lib/rubocop/graphql/argument.rb', line 25

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



23
24
25
# File 'lib/rubocop/graphql/argument.rb', line 23

def node
  @node
end

Instance Method Details

#argument_as(node) ⇒ Object



19
20
21
# File 'lib/rubocop/graphql/argument.rb', line 19

def_node_matcher :argument_as, <<~PATTERN
  (pair (sym :as) (sym $_))
PATTERN

#argument_description(node) ⇒ Object



9
10
11
# File 'lib/rubocop/graphql/argument.rb', line 9

def_node_matcher :argument_description, <<~PATTERN
  (send nil? :argument _ _ (:str $_) ...)
PATTERN

#argument_name(node) ⇒ Object



14
15
16
# File 'lib/rubocop/graphql/argument.rb', line 14

def_node_matcher :argument_name, <<~PATTERN
  (send nil? :argument (:sym $_) ...)
PATTERN

#asObject



33
34
35
# File 'lib/rubocop/graphql/argument.rb', line 33

def as
  @as ||= argument_as(kwargs.as)
end

#blockObject



45
46
47
# File 'lib/rubocop/graphql/argument.rb', line 45

def block
  @block ||= Argument::Block.new(@node.parent)
end

#descriptionObject



37
38
39
# File 'lib/rubocop/graphql/argument.rb', line 37

def description
  @description ||= argument_description(@node) || kwargs.description || block.description
end

#kwargsObject



41
42
43
# File 'lib/rubocop/graphql/argument.rb', line 41

def kwargs
  @kwargs ||= Argument::Kwargs.new(@node)
end

#nameObject



29
30
31
# File 'lib/rubocop/graphql/argument.rb', line 29

def name
  @name ||= argument_name(@node)
end