Skip to content

Commit f97b4d2

Browse files
author
Robert Mosolgo
authored
Merge pull request #1277 from rmosolgo/special-hash
Fix NO_TYPED_CHILDREN compatibility
2 parents 682bce8 + 510adc5 commit f97b4d2

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

  • lib/graphql/internal_representation

lib/graphql/internal_representation/node.rb

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,9 @@ class Node
66
DEFAULT_TYPED_CHILDREN = Proc.new { |h, k| h[k] = {} }
77

88
# A specialized, reusable object for leaf nodes.
9-
# Behaves like a Hash, but doesn't copy itself.
10-
# @api private
11-
class NoTypedChildren
12-
CHILDREN = {}.freeze
13-
def dup; self; end
14-
def any?; false; end
15-
def none?; true; end
16-
def [](key); CHILDREN; end
17-
def each; end
18-
19-
# Compatibility for when this was an Array:
20-
def method_missing(method_name, *args, &block)
21-
if CHILDREN.respond_to?(method_name)
22-
CHILDREN.send(method_name, *args, &block)
23-
else
24-
raise NotImplementedError
25-
end
26-
end
27-
end
28-
NO_TYPED_CHILDREN = NoTypedChildren.new
9+
NO_TYPED_CHILDREN = Hash.new([].freeze)
10+
def NO_TYPED_CHILDREN.dup; self; end;
11+
NO_TYPED_CHILDREN.freeze
2912

3013
# @return [String] the name this node has in the response
3114
attr_reader :name

0 commit comments

Comments
 (0)