Class: ExceptionNotifier::SlackNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::SlackNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exception_notifier/slack_notifier.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
Returns the value of attribute notifier.
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
- #deep_reject(hash, block) ⇒ Object
-
#initialize(options) ⇒ SlackNotifier
constructor
A new instance of SlackNotifier.
Methods included from BacktraceCleaner
Constructor Details
#initialize(options) ⇒ SlackNotifier
Returns a new instance of SlackNotifier.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/exception_notifier/slack_notifier.rb', line 7 def initialize() begin @ignore_data_if = [:ignore_data_if] webhook_url = .fetch(:webhook_url) @message_opts = .fetch(:additional_parameters, {}) @notifier = Slack::Notifier.new webhook_url, rescue @notifier = nil end end |
Instance Attribute Details
#notifier ⇒ Object
Returns the value of attribute notifier.
5 6 7 |
# File 'lib/exception_notifier/slack_notifier.rb', line 5 def notifier @notifier end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/exception_notifier/slack_notifier.rb', line 19 def call(exception, ={}) = "An exception occurred: '#{exception.}' on '#{exception.backtrace.first}'" = (, ) = (, exception) @notifier.ping(, @message_opts) if valid? end |
#deep_reject(hash, block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/exception_notifier/slack_notifier.rb', line 35 def deep_reject(hash, block) hash.each do |k, v| if v.is_a?(Hash) deep_reject(v, block) end if block.call(k, v) hash.delete(k) end end end |