Sha256: 1e2aa0882dfa78c4d74e47050606fef17b2c0f5210c9ec2f597bb8d695a26eac
Contents?: true
Size: 1.04 KB
Versions: 64
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module GraphQL module Execution class Interpreter # This response class handles `#write` by accumulating # values into a Hash. class HashResponse def initialize @result = {} end def final_value @result end def inspect "#<#{self.class.name} result=#{@result.inspect}>" end # Add `value` at `path`. # @return [void] def write(path, value) if path.empty? @result = value elsif (write_target = @result) i = 0 prefinal_steps = path.size - 1 # Use `while` to avoid a closure while i < prefinal_steps path_part = path[i] i += 1 write_target = write_target[path_part] end path_part = path[i] write_target[path_part] = value else # The response is completely nulled out end nil end end end end end
Version data entries
64 entries across 64 versions & 1 rubygems