Class: GraphQL::Client::QueryResult::ScalarWrapper
- Inherits:
-
Object
- Object
- GraphQL::Client::QueryResult::ScalarWrapper
- Defined in:
- lib/graphql/client/query_result.rb
Overview
:nodoc:
Instance Method Summary collapse
- #cast(value, _errors = nil) ⇒ Object
-
#initialize(type) ⇒ ScalarWrapper
constructor
A new instance of ScalarWrapper.
- #|(_other) ⇒ Object
Constructor Details
#initialize(type) ⇒ ScalarWrapper
Returns a new instance of ScalarWrapper.
171 172 173 |
# File 'lib/graphql/client/query_result.rb', line 171 def initialize(type) @type = type end |
Instance Method Details
#cast(value, _errors = nil) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/graphql/client/query_result.rb', line 175 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
193 194 195 196 |
# File 'lib/graphql/client/query_result.rb', line 193 def |(_other) # XXX: How would scalars merge? self end |