Module: Integrations::HasWebHook

Extended by:
ActiveSupport::Concern
Included in:
Buildkite, Datadog, DroneCi, Jenkins, Packagist
Defined in:
app/models/concerns/integrations/has_web_hook.rb

Instance Method Summary collapse

Instance Method Details

#execute_web_hook!(*args) ⇒ Object

Execute the webhook, creating it if necessary.


35
36
37
38
# File 'app/models/concerns/integrations/has_web_hook.rb', line 35

def execute_web_hook!(*args)
  update_web_hook!
  service_hook.execute(*args)
end

#hook_ssl_verificationObject

Return whether the webhook should use SSL verification.


17
18
19
20
21
22
23
# File 'app/models/concerns/integrations/has_web_hook.rb', line 17

def hook_ssl_verification
  if respond_to?(:enable_ssl_verification)
    enable_ssl_verification
  else
    true
  end
end

#hook_urlObject

Return the URL to be used for the webhook.

Raises:

  • (NotImplementedError)

12
13
14
# File 'app/models/concerns/integrations/has_web_hook.rb', line 12

def hook_url
  raise NotImplementedError
end

#update_web_hook!Object

Create or update the webhook, raising an exception if it cannot be saved.


26
27
28
29
30
31
32
# File 'app/models/concerns/integrations/has_web_hook.rb', line 26

def update_web_hook!
  hook = service_hook || build_service_hook
  hook.url = hook_url if hook.url != hook_url # avoid reencryption
  hook.enable_ssl_verification = hook_ssl_verification
  hook.save! if hook.changed?
  hook
end