Class: ExceptionNotifier::BearychatNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::BearychatNotifier
- Defined in:
- lib/exception_notifier/bearychat_notifier.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
include ExceptionNotifier::BacktraceCleaner # 不在 exception_notification 手动添加代码过来.
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
- #deep_reject(hash, block) ⇒ Object
-
#initialize(options) ⇒ BearychatNotifier
constructor
A new instance of BearychatNotifier.
Constructor Details
#initialize(options) ⇒ BearychatNotifier
Returns a new instance of BearychatNotifier.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/exception_notifier/bearychat_notifier.rb', line 8 def initialize() begin @ignore_data_if = [:ignore_data_if] webhook_url = .fetch(:webhook_url) .delete(:webhook_url) = [:attachments] = .fetch(:attachments, []) @notifier = Bearychat::Notifier.new webhook_url, rescue @notifier = nil end end |
Instance Attribute Details
#notifier ⇒ Object
include ExceptionNotifier::BacktraceCleaner # 不在 exception_notification 手动添加代码过来
6 7 8 |
# File 'lib/exception_notifier/bearychat_notifier.rb', line 6 def notifier @notifier end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/exception_notifier/bearychat_notifier.rb', line 22 def call(exception, ={}) text = "An exception occurred: '#{exception.message}' on '#{exception.backtrace.first}'" text = (text, ) = {} [:text] = (text, exception) [:attachments].push() @notifier.ping(text, ) if valid? end |
#deep_reject(hash, block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/exception_notifier/bearychat_notifier.rb', line 41 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 |