Sha256: afd6f1e5d2ecbc28c74bec7c5a43e75b323b04ead350e4b639b2cb93afb71c30
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Jace # @api private # @author Darthjee # # Class responsible for dispatching the call of events class Dispatcher # @param before [Symbol,Proc,Array] all the methods / proc # to be executed before block call # @param after [Symbol,Proc,Array] all the methods / proc # to be executed after block call def initialize(before: [], after: []) @before = [before].flatten.compact @after = [after].flatten.compact end # Dispatch the event call on a context # # @param context [Object] Object where the procs / methods # will be called on # @block [Proc] bloc to be performed between befores and afters # # @return [Object] result of block call def dispatch(context, &block) Executer.call( before: before, after: after, context: context, &block ) end private attr_reader :before, :after # @method before # @private # @api private # # Contains a list of event handlers to be called before # # @return [Array<Object>] list of handlers # @method after # @private # @api private # # Contains a list of event handlers to be called after # # @return [Array<Object>] list of handlers end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jace-0.1.1 | lib/jace/dispatcher.rb |
jace-0.1.0 | lib/jace/dispatcher.rb |