Class: RuboCop::GraphQL::SchemaMember
- Inherits:
-
Object
- Object
- RuboCop::GraphQL::SchemaMember
- Extended by:
- NodePattern::Macros
- Defined in:
- lib/rubocop/graphql/schema_member.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #body ⇒ Object
- #class_contents(node) ⇒ Object
- #find_method_definition(method_name) ⇒ Object
-
#initialize(node) ⇒ SchemaMember
constructor
A new instance of SchemaMember.
Constructor Details
#initialize(node) ⇒ SchemaMember
Returns a new instance of SchemaMember.
15 16 17 |
# File 'lib/rubocop/graphql/schema_member.rb', line 15 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
13 14 15 |
# File 'lib/rubocop/graphql/schema_member.rb', line 13 def node @node end |
Instance Method Details
#body ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubocop/graphql/schema_member.rb', line 23 def body contents = class_contents(@node) if contents.nil? [] elsif contents.begin_type? contents.child_nodes else [contents] end end |
#class_contents(node) ⇒ Object
9 10 11 |
# File 'lib/rubocop/graphql/schema_member.rb', line 9 def_node_matcher :class_contents, <<~PATTERN {(class _ _ $_) | (module _ $_)} PATTERN |
#find_method_definition(method_name) ⇒ Object
19 20 21 |
# File 'lib/rubocop/graphql/schema_member.rb', line 19 def find_method_definition(method_name) body.find { |node| node.def_type? && node.method?(method_name) } end |