Class: GraphQL::Client::QueryResult::Scalar

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/client/query_result.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Scalar

Returns a new instance of Scalar.



51
52
53
# File 'lib/graphql/client/query_result.rb', line 51

def initialize(type)
  @type = type
end

Instance Method Details

#cast(value, _errors = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/graphql/client/query_result.rb', line 55

def cast(value, _errors = nil)
  if value.is_a? Array
    value.map { |item|  @type.coerce_input(item) }
  else
    @type.coerce_input(value)
  end
end

#|(_other) ⇒ Object



63
64
65
66
# File 'lib/graphql/client/query_result.rb', line 63

def |(_other)
  # XXX: How would scalars merge?
  self
end