Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NO_TYPED_CHILDREN compatibility #1277

Merged
merged 3 commits into from
Feb 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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