Class: GraphQL::Client::QueryResult::ScalarWrapper

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ ScalarWrapper



169
170
171
# File 'lib/graphql/client/query_result.rb', line 169

def initialize(type)
  @type = type
end

Instance Method Details

#cast(value, _errors = nil) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/graphql/client/query_result.rb', line 173

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

#|(_other) ⇒ Object



191
192
193
194
# File 'lib/graphql/client/query_result.rb', line 191

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