Sha256: a68811cb3ad3b7be7348baa51d943d66b7ff708a7436dc8652b60d7c40b715ac
Contents?: true
Size: 915 Bytes
Versions: 15
Compression:
Stored size: 915 Bytes
Contents
module GraphQL class Schema # Given {steps} and {arguments}, call steps in order, passing `(*arguments, next_step)`. # # Steps should call `next_step.call` to continue the chain, or _not_ call it to stop the chain. class MiddlewareChain # @return [Array<#call(*args)>] Steps in this chain, will be called with arguments and `next_middleware` attr_reader :steps # @return [Array] Arguments passed to steps (followed by `next_middleware`) attr_reader :arguments def initialize(steps:, arguments:) # We're gonna destroy this array, so copy it: @steps = steps.dup @arguments = arguments end # Run the next step in the chain, passing in arguments and handle to the next step def call next_step = steps.shift next_middleware = self next_step.call(*arguments, next_middleware) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems