Class: Reji::WebhookController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/reji/webhook_controller.rb

Instance Method Summary collapse

Instance Method Details

#handle_webhookObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/reji/webhook_controller.rb', line 7

def handle_webhook
  payload = JSON.parse(request.body.read)

  type = payload['type']

  return self.missing_method if type.nil?

  method = "handle_#{payload['type'].gsub('.', '_')}"

  self.respond_to?(method, true) ?
    self.send(method, payload) :
    self.missing_method
end