Skip to content

Commit

Permalink
Merge pull request #1277 from rmosolgo/special-hash
Browse files Browse the repository at this point in the history
Fix NO_TYPED_CHILDREN compatibility
  • Loading branch information
Robert Mosolgo authored Feb 13, 2018
2 parents 682bce8 + 510adc5 commit f97b4d2
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions lib/graphql/internal_representation/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,9 @@ class Node
DEFAULT_TYPED_CHILDREN = Proc.new { |h, k| h[k] = {} }

# A specialized, reusable object for leaf nodes.
# Behaves like a Hash, but doesn't copy itself.
# @api private
class NoTypedChildren
CHILDREN = {}.freeze
def dup; self; end
def any?; false; end
def none?; true; end
def [](key); CHILDREN; end
def each; end

# Compatibility for when this was an Array:
def method_missing(method_name, *args, &block)
if CHILDREN.respond_to?(method_name)
CHILDREN.send(method_name, *args, &block)
else
raise NotImplementedError
end
end
end
NO_TYPED_CHILDREN = NoTypedChildren.new
NO_TYPED_CHILDREN = Hash.new([].freeze)
def NO_TYPED_CHILDREN.dup; self; end;
NO_TYPED_CHILDREN.freeze

# @return [String] the name this node has in the response
attr_reader :name
Expand Down

0 comments on commit f97b4d2

Please sign in to comment.