Class: CritsendEvents::WebhookProcessor
- Inherits:
-
Object
- Object
- CritsendEvents::WebhookProcessor
- Defined in:
- lib/critsend_events/webhook_processor.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
Instance Method Summary collapse
-
#initialize(handler) ⇒ WebhookProcessor
constructor
A new instance of WebhookProcessor.
- #process(data) ⇒ Object
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
#handler ⇒ Object (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 |