Class: Jace::Dispatcher Private

Inherits:
Object
  • Object
show all
Defined in:
lib/jace/dispatcher.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class responsible for dispatching the call of events

Author:

  • Darthjee

Instance Method Summary collapse

Constructor Details

#initialize(before: [], after: []) ⇒ Dispatcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Dispatcher.

Parameters:

  • before (Symbol, Proc, Array) (defaults to: [])

    all the methods / proc to be executed before block call

  • after (Symbol, Proc, Array) (defaults to: [])

    all the methods / proc to be executed after block call



13
14
15
16
# File 'lib/jace/dispatcher.rb', line 13

def initialize(before: [], after: [])
  @before = [before].flatten.compact
  @after = [after].flatten.compact
end

Instance Method Details

#dispatch(context, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Dispatch the event call on a context

Parameters:

  • context (Object)

    Object where the procs / methods will be called on

Returns:

  • (Object)

    result of block call



25
26
27
28
29
30
31
32
# File 'lib/jace/dispatcher.rb', line 25

def dispatch(context, &block)
  Executer.call(
    before: before,
    after: after,
    context: context,
    &block
  )
end