Class: GraphWeaver::Codegen::InputNode
- Inherits:
-
Object
- Object
- GraphWeaver::Codegen::InputNode
- Defined in:
- lib/graph_weaver/codegen/nodes.rb
Overview
An input-object variable: emitted as a module-level T::Struct whose serialize produces the wire hash. Inputs never cast FROM the wire. Joins the coerce protocol so execute kwargs accept plain hashes, normalized (and type-checked) through the generated .coerce.
Defined Under Namespace
Classes: Field
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #bare_type ⇒ Object
- #cast(_expr, _depth) ⇒ Object
- #coerce(expr) ⇒ Object
- #coerce? ⇒ Boolean
- #coerce_input_type ⇒ Object
-
#hash_coerce(expr, _depth) ⇒ Object
building a struct field from a caller-supplied plain hash value.
- #hash_coerce_identity? ⇒ Boolean
- #identity? ⇒ Boolean
-
#initialize(class_name) ⇒ InputNode
constructor
A new instance of InputNode.
- #nested ⇒ Object
- #non_null? ⇒ Boolean
- #prop_type ⇒ Object
- #serialize(expr, _depth) ⇒ Object
- #serialize_identity? ⇒ Boolean
Constructor Details
#initialize(class_name) ⇒ InputNode
Returns a new instance of InputNode.
323 324 325 326 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 323 def initialize(class_name) @class_name = class_name @fields = [] end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
321 322 323 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 321 def class_name @class_name end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
321 322 323 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 321 def fields @fields end |
Instance Method Details
#bare_type ⇒ Object
328 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 328 def = class_name |
#cast(_expr, _depth) ⇒ Object
340 341 342 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 340 def cast(_expr, _depth) raise NotImplementedError, "input objects are never cast from responses" end |
#coerce(expr) ⇒ Object
345 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 345 def coerce(expr) = "#{class_name}.coerce(#{expr})" |
#coerce? ⇒ Boolean
344 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 344 def coerce? = true |
#coerce_input_type ⇒ Object
346 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 346 def coerce_input_type = "T.any(#{class_name}, T::Hash[T.untyped, T.untyped])" |
#hash_coerce(expr, _depth) ⇒ Object
building a struct field from a caller-supplied plain hash value
349 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 349 def hash_coerce(expr, _depth) = "#{class_name}.coerce(#{expr})" |
#hash_coerce_identity? ⇒ Boolean
350 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 350 def hash_coerce_identity? = false |
#identity? ⇒ Boolean
352 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 352 def identity? = false |
#nested ⇒ Object
354 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 354 def nested = nil |
#non_null? ⇒ Boolean
353 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 353 def non_null? = false |
#prop_type ⇒ Object
330 331 332 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 330 def prop_type "T.nilable(#{})" end |
#serialize(expr, _depth) ⇒ Object
334 335 336 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 334 def serialize(expr, _depth) "#{expr}.serialize" end |
#serialize_identity? ⇒ Boolean
338 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 338 def serialize_identity? = false |