Class: GraphWeaver::Codegen::NarrowedNode
- Inherits:
-
Object
- Object
- GraphWeaver::Codegen::NarrowedNode
- Defined in:
- lib/graph_weaver/codegen/nodes.rb
Overview
A single-condition narrowing of an abstract field (... on Pet { ... }
and nothing else): the member struct when the runtime type matches,
nil when it doesn't — a non-match's response object carries no
matching fields, so the hash arrives empty. Always nilable, whatever
the schema's nullability, because narrowing filters.
Instance Method Summary collapse
- #bare_type ⇒ Object
- #cast(expr, depth) ⇒ Object
- #class_name ⇒ Object
- #identity? ⇒ Boolean
-
#initialize(of) ⇒ NarrowedNode
constructor
A new instance of NarrowedNode.
- #nested ⇒ Object
- #non_null? ⇒ Boolean
- #prop_type ⇒ Object
Constructor Details
#initialize(of) ⇒ NarrowedNode
Returns a new instance of NarrowedNode.
271 272 273 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 271 def initialize(of) @of = of end |
Instance Method Details
#bare_type ⇒ Object
276 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 276 def = @of. |
#cast(expr, depth) ⇒ Object
282 283 284 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 282 def cast(expr, depth) "(#{expr}.empty? ? nil : #{@of.cast(expr, depth)})" end |
#class_name ⇒ Object
275 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 275 def class_name = @of.class_name |
#identity? ⇒ Boolean
286 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 286 def identity? = false |
#nested ⇒ Object
288 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 288 def nested = @of |
#non_null? ⇒ Boolean
287 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 287 def non_null? = false |
#prop_type ⇒ Object
278 279 280 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 278 def prop_type "T.nilable(#{})" end |