class GraphQL::Client::Schema::ScalarType
Public Class Methods
new(type)
click to toggle source
Internal: Construct type wrapper from another GraphQL::BaseType.
type - GraphQL::BaseType instance
# 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
Public Instance Methods
cast(value, _errors = nil)
click to toggle source
Internal: Cast raw JSON value to Ruby scalar object.
value - JSON value errors - Errors
instance
Returns casted Object.
# 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)
click to toggle source
# File lib/graphql/client/schema/scalar_type.rb, line 22 def define_class(definition, ast_nodes) self end