Method: GraphQL::Language::Nodes::AbstractNode#delete_child
- Defined in:
- lib/graphql/language/nodes.rb
#delete_child(previous_child) ⇒ Object
TODO DRY with replace_child
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/graphql/language/nodes.rb', line 114 def delete_child(previous_child) # Figure out which list `previous_child` may be found in method_name = previous_child.children_method_name # Copy that list, and delete previous_child new_children = public_send(method_name).dup new_children.delete(previous_child) # Copy this node, but with the new list of children: copy_of_self = merge(method_name => new_children) # Return the copy: copy_of_self end |