class Contentful::Webhook::Listener::WebhookFactory
Public Class Methods
new(request)
click to toggle source
# File lib/contentful/webhook/listener/webhooks.rb, line 12 def initialize(request) @headers = {} request.each { |header, value| @headers[header.downcase] = value } @body = JSON.load(request.body) end
Public Instance Methods
create()
click to toggle source
# File lib/contentful/webhook/listener/webhooks.rb, line 18 def create webhook_class.new(@headers, @body) end
Private Instance Methods
webhook_class()
click to toggle source
# File lib/contentful/webhook/listener/webhooks.rb, line 24 def webhook_class Object.const_get(webhook_class_name) end
webhook_class_name()
click to toggle source
# File lib/contentful/webhook/listener/webhooks.rb, line 28 def webhook_class_name event_name = @headers[::Contentful::Webhook::Listener::WebhookConstants::WEBHOOK_TOPIC].split('.')[-1].split('_').collect(&:capitalize).join "Contentful::Webhook::Listener::#{event_name}Webhook" rescue Exception fail 'Could not detect Webhook class' end