Class: GraphWeaver::Codegen::ObjectNode

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_weaver/codegen.rb

Defined Under Namespace

Classes: Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ ObjectNode

Returns a new instance of ObjectNode.



135
136
137
138
# File 'lib/graph_weaver/codegen.rb', line 135

def initialize(class_name)
  @class_name = class_name
  @fields = []
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



133
134
135
# File 'lib/graph_weaver/codegen.rb', line 133

def class_name
  @class_name
end

#fieldsObject (readonly)

Returns the value of attribute fields.



133
134
135
# File 'lib/graph_weaver/codegen.rb', line 133

def fields
  @fields
end

Instance Method Details

#bare_typeObject



140
# File 'lib/graph_weaver/codegen.rb', line 140

def bare_type = class_name

#cast(expr, _depth) ⇒ Object



146
147
148
# File 'lib/graph_weaver/codegen.rb', line 146

def cast(expr, _depth)
  "#{class_name}.from_h(#{expr})"
end

#identity?Boolean

Returns:

  • (Boolean)


150
# File 'lib/graph_weaver/codegen.rb', line 150

def identity? = false

#nestedObject



152
# File 'lib/graph_weaver/codegen.rb', line 152

def nested = self

#non_null?Boolean

Returns:

  • (Boolean)


151
# File 'lib/graph_weaver/codegen.rb', line 151

def non_null? = false

#prop_typeObject



142
143
144
# File 'lib/graph_weaver/codegen.rb', line 142

def prop_type
  "T.nilable(#{bare_type})"
end