Module: GraphqlRails::Attributes::Attributable
- Included in:
- Attribute, InputAttribute
- Defined in:
- lib/graphql_rails/attributes/attributable.rb
Overview
contains methods which are shared between various attribute-like classes expects ‘initial_name` and `type` to be defined
Instance Method Summary collapse
- #field_name ⇒ Object
- #graphql_model ⇒ Object
- #initialize_copy(_original) ⇒ Object
- #name ⇒ Object
- #optional? ⇒ Boolean
- #required? ⇒ Boolean
- #scalar_type? ⇒ Boolean
- #type_name ⇒ Object
Instance Method Details
#field_name ⇒ Object
17 18 19 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 17 def field_name attribute_name_parser.field_name end |
#graphql_model ⇒ Object
37 38 39 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 37 def graphql_model type_parser.graphql_model end |
#initialize_copy(_original) ⇒ Object
11 12 13 14 15 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 11 def initialize_copy(_original) super @attribute_name_parser = nil @type_parser = nil end |
#name ⇒ Object
25 26 27 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 25 def name attribute_name_parser.name end |
#optional? ⇒ Boolean
41 42 43 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 41 def optional? !required? end |
#required? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 29 def required? return @required unless @required.nil? (type.nil? && attribute_name_parser.required?) || type.to_s[/!$/].present? || type.is_a?(GraphQL::Schema::NonNull) end |
#scalar_type? ⇒ Boolean
45 46 47 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 45 def scalar_type? type_parser.raw_graphql_type? || type_parser.core_scalar_type? end |
#type_name ⇒ Object
21 22 23 |
# File 'lib/graphql_rails/attributes/attributable.rb', line 21 def type_name type.to_s end |