123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Schema::ScalarType

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, BaseType
Inherits: Object
Defined in: lib/graphql/client/schema/scalar_type.rb

Class Method Summary

Instance Attribute Summary

BaseType - Included

#schema_module

Internal: Get owner schema Module container.

#type

Public: Get associated GraphQL::BaseType with for this class.

Instance Method Summary

BaseType - Included

#cast

Internal: Cast JSON value to wrapped value.

#to_list_type

Internal: Get list wrapper of this type class.

#to_non_null_type

Internal: Get non-nullable wrapper of this type class.

Constructor Details

.new(type) ⇒ ScalarType

Internal: Construct type wrapper from another GraphQL::BaseType.

type - GraphQL::BaseType instance

[ GitHub ]

  
# File 'lib/graphql/client/schema/scalar_type.rb', line 14

def initialize(type)
  unless type.kind.scalar?
    raise "expected type to be a Scalar, but was #{type.class}"
  end

  @type = type
end

Instance Method Details

#cast(value, _errors = nil)

Internal: Cast raw JSON value to Ruby scalar object.

value - JSON value errors - ::GraphQL::Client::Errors instance

Returns casted Object.

[ GitHub ]

  
# File 'lib/graphql/client/schema/scalar_type.rb', line 32

def cast(value, _errors = nil)
  case value
  when NilClass
    nil
  else
    if type.respond_to?(:coerce_isolated_input)
      type.coerce_isolated_input(value)
    else
      type.coerce_input(value)
    end
  end
end

#define_class(definition, ast_nodes)

[ GitHub ]

  
# File 'lib/graphql/client/schema/scalar_type.rb', line 22

def define_class(definition, ast_nodes)
  self
end