Class: GraphQL::Client::QueryResult::ListWrapper
- Inherits:
-
Object
- Object
- GraphQL::Client::QueryResult::ListWrapper
- Defined in:
- lib/graphql/client/query_result.rb
Instance Method Summary collapse
- #cast(value, errors) ⇒ Object
-
#initialize(type) ⇒ ListWrapper
constructor
A new instance of ListWrapper.
- #|(other) ⇒ Object
Constructor Details
#initialize(type) ⇒ ListWrapper
100 101 102 |
# File 'lib/graphql/client/query_result.rb', line 100 def initialize(type) @of_klass = type end |
Instance Method Details
#cast(value, errors) ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/graphql/client/query_result.rb', line 104 def cast(value, errors) case value when Array List.new(value.each_with_index.map { |e, idx| @of_klass.cast(e, errors.filter_by_path(idx)) }, errors) else raise ArgumentError, "expected list value to be an Array, but was #{value.class}" end end |
#|(other) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/graphql/client/query_result.rb', line 115 def |(other) if self.class == other.class self.of_klass | other.of_klass else raise TypeError, "expected other to be a #{self.class}" end end |