Class: GraphqlRails::Attributes::TypeNameInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_rails/attributes/type_name_info.rb

Overview

checks various attributes based on graphql type name

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ TypeNameInfo

Returns a new instance of TypeNameInfo.



9
10
11
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 9

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 7

def name
  @name
end

Instance Method Details

#inner_nameObject



17
18
19
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 17

def inner_name
  name[/[^!\[\]]+!?/]
end

#list?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 25

def list?
  name.include?(']')
end

#nullable_inner_nameObject



13
14
15
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 13

def nullable_inner_name
  inner_name[/[^!]+/]
end

#required?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 29

def required?
  name.end_with?('!')
end

#required_inner_type?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 21

def required_inner_type?
  inner_name.include?('!')
end

#required_list?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 33

def required_list?
  required? && list?
end