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.
313 314 315 316 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 313 def initialize(class_name) @class_name = class_name @fields = [] end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
311 312 313 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 311 def class_name @class_name end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
311 312 313 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 311 def fields @fields end |
Instance Method Details
#bare_type ⇒ Object
318 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 318 def = class_name |
#cast(_expr, _depth) ⇒ Object
324 325 326 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 324 def cast(_expr, _depth) raise GraphWeaver::Error, "input objects are never cast from responses" end |
#coerce(expr) ⇒ Object
329 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 329 def coerce(expr) = "#{class_name}.coerce(#{expr})" |
#coerce? ⇒ Boolean
328 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 328 def coerce? = true |
#coerce_input_type ⇒ Object
330 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 330 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
333 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 333 def hash_coerce(expr, _depth) = "#{class_name}.coerce(#{expr})" |
#serialize(expr, _depth) ⇒ Object
320 321 322 |
# File 'lib/graph_weaver/codegen/nodes.rb', line 320 def serialize(expr, _depth) "#{expr}.serialize" end |