Class: GraphWeaver::Codegen::List
- Inherits:
-
Node
- Object
- Node
- GraphWeaver::Codegen::List
show all
- Defined in:
- lib/graph_weaver/codegen/nodes.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Node
#coerce?, #non_null?, #prop_type
Constructor Details
#initialize(of) ⇒ List
Returns a new instance of List.
96
97
98
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 96
def initialize(of)
@of = of
end
|
Instance Attribute Details
#of ⇒ Object
Returns the value of attribute of.
94
95
96
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 94
def of
@of
end
|
Instance Method Details
#bare_type ⇒ Object
100
101
102
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 100
def bare_type
"T::Array[#{@of.prop_type}]"
end
|
#cast(expr, depth) ⇒ Object
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 104
def cast(expr, depth)
var = "v#{depth}"
element = if @of.non_null? || @of.identity?
@of.identity? ? var : @of.cast(var, depth + 1)
else
"#{var}&.then { |v#{depth + 1}| #{@of.cast("v#{depth + 1}", depth + 2)} }"
end
"#{expr}.map { |#{var}| #{element} }"
end
|
#hash_coerce(expr, depth) ⇒ Object
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 130
def hash_coerce(expr, depth)
var = "v#{depth}"
inner = if @of.non_null? || @of.hash_coerce_identity?
@of.hash_coerce_identity? ? var : @of.hash_coerce(var, depth + 1)
else
"#{var}&.then { |v#{depth + 1}| #{@of.hash_coerce("v#{depth + 1}", depth + 2)} }"
end
"#{expr}.map { |#{var}| #{inner} }"
end
|
#hash_coerce_identity? ⇒ Boolean
141
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 141
def hash_coerce_identity? = @of.hash_coerce_identity?
|
#identity? ⇒ Boolean
115
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 115
def identity? = @of.identity?
|
#nested ⇒ Object
142
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 142
def nested = @of.nested
|
#serialize(expr, depth) ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 117
def serialize(expr, depth)
var = "v#{depth}"
element = if @of.non_null? || @of.serialize_identity?
@of.serialize_identity? ? var : @of.serialize(var, depth + 1)
else
"#{var}&.then { |v#{depth + 1}| #{@of.serialize("v#{depth + 1}", depth + 2)} }"
end
"#{expr}.map { |#{var}| #{element} }"
end
|
#serialize_identity? ⇒ Boolean
128
|
# File 'lib/graph_weaver/codegen/nodes.rb', line 128
def serialize_identity? = @of.serialize_identity?
|