Module: Icalia::Event::Subscriber

Extended by:
ActiveSupport::Concern
Defined in:
lib/icalia/event/subscriber.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#perform(message) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/icalia/event/subscriber.rb', line 19

def perform(message)
  raw_data = MessagePack.unpack(message.data)
  event = Icalia::Deserializer.new(raw_data).perform
  event_class_name = event.class.name.demodulize

  if (processor_class = processor_map[event_class_name])
    (processor = processor_class.new(event, message.attributes)).perform
  else
    logger.info "There's no mapped processor for #{event_class_name}"
  end
  
  message.acknowledge!
end