Class: CritsendEvents::WebhookProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/critsend_events/webhook_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler) ⇒ WebhookProcessor

Returns a new instance of WebhookProcessor.



4
5
6
7
# File 'lib/critsend_events/webhook_processor.rb', line 4

def initialize(handler)
  handler = constantize(handler).new if handler.is_a?(String)
  @handler = handler
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



3
4
5
# File 'lib/critsend_events/webhook_processor.rb', line 3

def handler
  @handler
end

Instance Method Details

#process(data) ⇒ Object



9
10
11
12
# File 'lib/critsend_events/webhook_processor.rb', line 9

def process(data)
  events = JSON.parse(data)
  @handler.handle(events) if @handler.respond_to?(:handle)
end