class UniformNotifier::Slack
Constants
- POSSIBLE_OPTIONS
Public Class Methods
active?()
click to toggle source
# File lib/uniform_notifier/slack.rb, line 10 def active? @slack end
setup_connection(config = {})
click to toggle source
# 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
Protected Class Methods
_out_of_channel_notify(data)
click to toggle source
# File lib/uniform_notifier/slack.rb, line 26 def _out_of_channel_notify(data) message = data.values.compact.join("\n") notify(message) end
Private Class Methods
fail_connection(message)
click to toggle source
# File lib/uniform_notifier/slack.rb, line 33 def fail_connection(message) @slack = nil raise NotificationError, message end
notify(message)
click to toggle source
# File lib/uniform_notifier/slack.rb, line 38 def notify(message) @slack.ping message end
parse_config(config)
click to toggle source
# File lib/uniform_notifier/slack.rb, line 42 def parse_config(config) options = config.select { |name, value| POSSIBLE_OPTIONS.include?(name) && !value.nil? } [config[:webhook_url], options] end