Module: Rlyeh::Dispatcher

Included in:
Base, Rlyeh::DeepOnes::Auth::Base, Rlyeh::DeepOnes::Closer
Defined in:
lib/rlyeh/dispatcher.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/rlyeh/dispatcher.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#dispatch(env) ⇒ Object



38
39
40
41
42
43
# File 'lib/rlyeh/dispatcher.rb', line 38

def dispatch(env)
  if env.has_event?
    target = env.event
    trigger target, env
  end
end

#trigger(target, *args, &block) ⇒ Object



45
46
47
48
49
50
# File 'lib/rlyeh/dispatcher.rb', line 45

def trigger(target, *args, &block)
  callbacks = self.class.callbacks target
  callbacks.each do |callback|
    break if callback.bind(self).call(*args, &block) == false
  end
end