Class: GraphqlRails::Attributes::TypeNameInfo
- Inherits:
-
Object
- Object
- GraphqlRails::Attributes::TypeNameInfo
- Defined in:
- lib/graphql_rails/attributes/type_name_info.rb
Overview
checks various attributes based on graphql type name
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ TypeNameInfo
constructor
A new instance of TypeNameInfo.
- #inner_name ⇒ Object
- #list? ⇒ Boolean
- #nullable_inner_name ⇒ Object
- #required? ⇒ Boolean
- #required_inner_type? ⇒ Boolean
- #required_list? ⇒ Boolean
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
#name ⇒ Object (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_name ⇒ Object
17 18 19 |
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 17 def inner_name name[/[^!\[\]]+!?/] end |
#list? ⇒ Boolean
25 26 27 |
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 25 def list? name.include?(']') end |
#nullable_inner_name ⇒ Object
13 14 15 |
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 13 def nullable_inner_name inner_name[/[^!]+/] end |
#required? ⇒ 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
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
33 34 35 |
# File 'lib/graphql_rails/attributes/type_name_info.rb', line 33 def required_list? required? && list? end |