Method: MessageChannel::Observer#action

Defined in:
lib/message_channel/observer.rb

#action(topic, message) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/message_channel/observer.rb', line 26

def action( topic, message )
  items  =  JSON.parse( message, symbolize_names: true )
  @asyncs.keys.each do |pattern|
    if File.fnmatch( pattern, topic, File::FNM_PATHNAME )
      if ( action  =  @asyncs[pattern] )
        action.call( topic, items )
      end
    end
  end
  @awaits.keys.each do |queue|
    @awaits[queue].each do |pattern|
      if File.fnmatch( pattern, topic, File::FNM_PATHNAME )
        queue.push( [topic, items] )
      end
    end
  end
end