Class: Shouter::Listeners::Async

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/shouter/listeners/async.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

included

Instance Attribute Details

#thread_existsObject (readonly)

Returns the value of attribute thread_exists.



7
8
9
# File 'lib/shouter/listeners/async.rb', line 7

def thread_exists
  @thread_exists
end

Instance Method Details

#notify!(scope, event, args, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/shouter/listeners/async.rb', line 9

def notify!(scope, event, args, &block)
  return unless notify?(scope, event)
  return if thread_exists?

  create_thread
  Thread.new do
    object.public_send(event, *args)
    fire_hook!(options[:callback] || block)
  end
  unregister(object)
end