Sha256: 6b43907dc4fcc59f084fad58a0a682e848fd516ea618f824feeb0f06a8329dfd
Contents?: true
Size: 680 Bytes
Versions: 18
Compression:
Stored size: 680 Bytes
Contents
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
18 entries across 18 versions & 1 rubygems