Class: GraphQL::Client::Schema::NonNullType
- Inherits:
-
Object
- Object
- GraphQL::Client::Schema::NonNullType
- Includes:
- BaseType
- Defined in:
- lib/graphql/client/schema/non_null_type.rb
Instance Attribute Summary collapse
-
#of_klass ⇒ Object
readonly
Internal: Get wrapped klass.
Attributes included from BaseType
Instance Method Summary collapse
-
#cast(value, errors) ⇒ Object
Internal: Cast JSON value to wrapped value.
-
#initialize(of_klass) ⇒ NonNullType
constructor
Internal: Construct non-nullable wrapper from other BaseType.
-
#to_non_null_type ⇒ Object
Internal: Get non-nullable wrapper of this type class.
Methods included from BaseType
Constructor Details
#initialize(of_klass) ⇒ NonNullType
Internal: Construct non-nullable wrapper from other BaseType.
of_klass - BaseType instance
15 16 17 18 19 20 21 |
# File 'lib/graphql/client/schema/non_null_type.rb', line 15 def initialize(of_klass) unless of_klass.is_a?(BaseType) raise TypeError, "expected #{of_klass.inspect} to be a #{BaseType}" end @of_klass = of_klass end |
Instance Attribute Details
#of_klass ⇒ Object (readonly)
Internal: Get wrapped klass.
Returns BaseType instance.
26 27 28 |
# File 'lib/graphql/client/schema/non_null_type.rb', line 26 def of_klass @of_klass end |
Instance Method Details
#cast(value, errors) ⇒ Object
Internal: Cast JSON value to wrapped value.
value - JSON value errors - Errors instance
Returns BaseType instance.
34 35 36 37 38 39 40 41 |
# File 'lib/graphql/client/schema/non_null_type.rb', line 34 def cast(value, errors) case value when NilClass raise InvariantError, "expected value to be non-nullable, but was nil" else of_klass.cast(value, errors) end end |
#to_non_null_type ⇒ Object
Internal: Get non-nullable wrapper of this type class.
Returns NonNullType instance.
46 47 48 |
# File 'lib/graphql/client/schema/non_null_type.rb', line 46 def to_non_null_type self end |