Class: 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.
-
#initialize(class_name) ⇒ InputNode
constructor
A new instance of InputNode.
- #serialize(expr, _depth) ⇒ Object
Methods inherited from Node
#hash_coerce_identity?, #identity?, #nested, #non_null?, #prop_type, #serialize_identity?
Constructor Details
#initialize(class_name) ⇒ InputNode
Returns a new instance of InputNode.
289 290 291 292 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 289 def initialize(class_name) @class_name = class_name @fields = [] end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
287 288 289 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 287 def class_name @class_name end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
287 288 289 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 287 def fields @fields end |
Instance Method Details
#bare_type ⇒ Object
294 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 294 def = class_name |
#cast(_expr, _depth) ⇒ Object
300 301 302 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 300 def cast(_expr, _depth) raise GraphWeaver::Error, "input objects are never cast from responses" end |
#coerce(expr) ⇒ Object
305 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 305 def coerce(expr) = "#{class_name}.coerce(#{expr})" |
#coerce? ⇒ Boolean
304 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 304 def coerce? = true |
#coerce_input_type ⇒ Object
306 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 306 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
309 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 309 def hash_coerce(expr, _depth) = "#{class_name}.coerce(#{expr})" |
#serialize(expr, _depth) ⇒ Object
296 297 298 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 296 def serialize(expr, _depth) "#{expr}.serialize" end |