Class: RuboCop::GraphQL::Argument::Kwargs

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

Instance Method Summary collapse

Constructor Details

#initialize(argument_node) ⇒ Kwargs

Returns a new instance of Kwargs.



39
40
41
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 39

def initialize(argument_node)
  @nodes = argument_kwargs(argument_node) || []
end

Instance Method Details

#argument_kwargs(node) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 10

def_node_matcher :argument_kwargs, <<~PATTERN
  (send nil? :argument
    ...
    (hash
      $...
    )
  )
PATTERN

#asObject



55
56
57
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 55

def as
  @nodes.find { |kwarg| as_kwarg?(kwarg) }
end

#as_kwarg?(node) ⇒ Object



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

def_node_matcher :as_kwarg?, <<~PATTERN
  (pair (sym :as) ...)
PATTERN

#camelizeObject



47
48
49
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 47

def camelize
  @nodes.find { |kwarg| camelize_kwarg?(kwarg) }
end

#camelize_kwarg?(node) ⇒ Object



35
36
37
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 35

def_node_matcher :camelize_kwarg?, <<~PATTERN
  (pair (sym :camelize) ...)
PATTERN

#descriptionObject



43
44
45
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 43

def description
  @nodes.find { |kwarg| description_kwarg?(kwarg) }
end

#description_kwarg?(node) ⇒ Object



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

def_node_matcher :description_kwarg?, <<~PATTERN
  (pair (sym :description) ...)
PATTERN

#loadsObject



51
52
53
# File 'lib/rubocop/graphql/argument/kwargs.rb', line 51

def loads
  @nodes.find { |kwarg| loads_kwarg?(kwarg) }
end

#loads_kwarg?(node) ⇒ Object



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

def_node_matcher :loads_kwarg?, <<~PATTERN
  (pair (sym :loads) ...)
PATTERN