Module: SlackErrorNotifier

Extended by:
Configuration
Defined in:
lib/slack_error_notifier.rb,
lib/slack_error_notifier/version.rb,
lib/slack_error_notifier/slack_notification.rb,
lib/slack_error_notifier/slack_configuration.rb

Defined Under Namespace

Modules: ConfigurationError Classes: SlackConfiguration, SlackNotification

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Methods included from Configuration

configuration, define_setting

Class Method Details

.check_configuration(block_given) ⇒ Object



38
39
40
41
# File 'lib/slack_error_notifier.rb', line 38

def self.check_configuration(block_given)
  raise ConfigurationError::NoBlockGivenError unless block_given
  raise ConfigurationError::MissingConfiguration unless access_token && target_channel
end

.configure_slack_clientObject



26
27
28
# File 'lib/slack_error_notifier.rb', line 26

def self.configure_slack_client
  @slack_configuration = SlackConfiguration.new
end

.send_notification(error) ⇒ Object



34
35
36
# File 'lib/slack_error_notifier.rb', line 34

def self.send_notification(error)
  SlackNotification.send(error)
end

.slack_clientObject



30
31
32
# File 'lib/slack_error_notifier.rb', line 30

def self.slack_client
  @slack_configuration.slack_client
end

.with_notificationsObject



17
18
19
20
21
22
23
24
# File 'lib/slack_error_notifier.rb', line 17

def self.with_notifications
  check_configuration(block_given?)
  configure_slack_client
  yield
rescue => error
  puts "Encountered #{error}. Sending Notification to #{target_channel}."
  send_notification(error)
end