Class: GraphQL::Client::Schema::IncludeDirective

Inherits:
Object
  • Object
show all
Includes:
BaseType
Defined in:
lib/graphql/client/schema/include_directive.rb

Instance Attribute Summary collapse

Attributes included from BaseType

#schema_module, #type

Instance Method Summary collapse

Methods included from BaseType

#to_list_type, #to_non_null_type

Constructor Details

#initialize(of_klass) ⇒ IncludeDirective

Internal: Construct list wrapper from other BaseType.

of_klass - BaseType instance



14
15
16
17
18
19
20
# File 'lib/graphql/client/schema/include_directive.rb', line 14

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_klassObject (readonly)

Internal: Get wrapped klass.

Returns BaseType instance.



25
26
27
# File 'lib/graphql/client/schema/include_directive.rb', line 25

def of_klass
  @of_klass
end

Instance Method Details

#cast(value, errors) ⇒ Object

Internal: Cast JSON value to wrapped value.

values - JSON value errors - Errors instance

Returns List instance or nil.



33
34
35
36
37
38
39
40
# File 'lib/graphql/client/schema/include_directive.rb', line 33

def cast(value, errors)
  case value
  when NilClass
    nil
  else
    of_klass.cast(value, errors)
  end
end