class SlackErrorNotifier::SlackNotification
Public Class Methods
new(error)
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 3 def initialize(error) @error = error end
send(error)
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 7 def self.send(error) new(error).send end
Public Instance Methods
send()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 11 def send slack_client.chat_postMessage( channel: target_channel, text: "", attachments: attachments, as_user: send_as_user ) end
Private Instance Methods
app_name()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 54 def app_name SlackErrorNotifier.app_name end
assemble_text_body()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 50 def assemble_text_body "#{Time.new.strftime("At %I:%M%p")}, an error occurred: `#{@error.inspect}` with the following stack trace: ```#{@error.backtrace.join("\n\t")}```" end
attachments()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 34 def attachments [{ fallback: "Error in #{app_name}", color: "danger", title: "Error in #{app_name}!", text: assemble_text_body, mrkdwn_in: ['text'], thumb_url: 'http://i.imgur.com/ILN6Klm.gif', fields: [{ "title": "Project", "value": "#{app_name}", "short": true }] }] end
send_as_user()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 30 def send_as_user SlackErrorNotifier.send_as_user end
slack_client()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 22 def slack_client SlackErrorNotifier.slack_client end
target_channel()
click to toggle source
# File lib/slack_error_notifier/slack_notification.rb, line 26 def target_channel SlackErrorNotifier.target_channel end