Class: GraphQL::Client::QueryResult::ListWrapper
- Inherits:
-
Object
- Object
- GraphQL::Client::QueryResult::ListWrapper
- Defined in:
- lib/graphql/client/query_result.rb
Instance Attribute Summary collapse
-
#of_klass ⇒ Object
readonly
Returns the value of attribute of_klass.
Instance Method Summary collapse
- #cast(value, errors) ⇒ Object
-
#initialize(type) ⇒ ListWrapper
constructor
A new instance of ListWrapper.
- #|(other) ⇒ Object
Constructor Details
#initialize(type) ⇒ ListWrapper
Returns a new instance of ListWrapper.
98 99 100 |
# File 'lib/graphql/client/query_result.rb', line 98 def initialize(type) @of_klass = type end |
Instance Attribute Details
#of_klass ⇒ Object (readonly)
Returns the value of attribute of_klass.
96 97 98 |
# File 'lib/graphql/client/query_result.rb', line 96 def of_klass @of_klass end |
Instance Method Details
#cast(value, errors) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/graphql/client/query_result.rb', line 102 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) when NilClass nil 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 |