Sha256: 425b1f2b4bb5d2ea8389acf0773f92f92d6a9d6c7f1cd6fef0eab405fe628c53
Contents?: true
Size: 710 Bytes
Versions: 1
Compression:
Stored size: 710 Bytes
Contents
# frozen_string_literal: true module DispatchRider module Callbacks # Provides access for invoking callbacks. class Access attr_reader :callbacks def initialize(callbacks) @callbacks = callbacks end # Executes the passed block wrapped in the event's callbacks. # @param [Symbol] event # @param [Array] args # @param [Proc] block def invoke(event, *args, &block) stack_of_callbacks = callbacks.for(event).reverse block_with_callbacks = stack_of_callbacks.reduce(block) { |inner_block, outer_block| -> { outer_block.call(inner_block, *args) } } block_with_callbacks.call end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dispatch-rider-2.2.0 | lib/dispatch-rider/callbacks/access.rb |