Class: ExceptionNotifier::SlackNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::SlackNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exception_notifier/slack_notifier.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
Returns the value of attribute notifier.
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ SlackNotifier
constructor
A new instance of SlackNotifier.
Methods included from BacktraceCleaner
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options) ⇒ SlackNotifier
Returns a new instance of SlackNotifier.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/exception_notifier/slack_notifier.rb', line 9 def initialize() super begin @ignore_data_if = [:ignore_data_if] @backtrace_lines = .fetch(:backtrace_lines, 10) @additional_fields = [:additional_fields] webhook_url = .fetch(:webhook_url) @message_opts = .fetch(:additional_parameters, {}) @color = @message_opts.delete(:color) { 'danger' } @notifier = Slack::Notifier.new webhook_url, rescue StandardError @notifier = nil end end |
Instance Attribute Details
#notifier ⇒ Object
Returns the value of attribute notifier.
7 8 9 |
# File 'lib/exception_notifier/slack_notifier.rb', line 7 def notifier @notifier end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/exception_notifier/slack_notifier.rb', line 25 def call(exception, = {}) = exception..tr('`', "'") attchs = attchs(exception, , ) return unless valid? args = [exception, , , @message_opts.merge(attachments: attchs)] send_notice(*args) do |_msg, | [:channel] = [:channel] if .key?(:channel) @notifier.ping '', end end |