Class: UniformNotifier::Slack

Inherits:
Base
  • Object
show all
Defined in:
lib/uniform_notifier/slack.rb

Constant Summary collapse

POSSIBLE_OPTIONS =
%i[username channel].freeze

Class Method Summary collapse

Methods inherited from Base

inline_notify, out_of_channel_notify

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/uniform_notifier/slack.rb', line 10

def active?
  @slack
end

.setup_connection(config = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/uniform_notifier/slack.rb', line 14

def setup_connection(config = {})
  webhook_url, options = parse_config(config)
  fail_connection('webhook_url required for Slack notification') unless webhook_url

  require 'slack-notifier'
  @slack = ::Slack::Notifier.new webhook_url, options
rescue LoadError
  fail_connection 'You must install the slack-notifier gem to use Slack notification: `gem install slack-notifier`'
end