Module: Chatterbox

Extended by:
Chatterbox
Included in:
Chatterbox
Defined in:
lib/chatterbox/version.rb,
lib/chatterbox.rb,
lib/chatterbox/services.rb,
lib/chatterbox/rails_catcher.rb,
lib/chatterbox/exception_notification.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ExceptionNotification, Publishers, RailsCatcher, Services, Version

Instance Method Summary collapse

Instance Method Details

#deprecate(message, callstack) ⇒ Object


31
32
33
# File 'lib/chatterbox.rb', line 31

def deprecate(message, callstack)
  ActiveSupport::Deprecation.warn(message, callstack)
end

#handle_notice(message) ⇒ Object

Deprecated version of #notify


25
26
27
28
29
# File 'lib/chatterbox.rb', line 25

def handle_notice(message)
  warning = "Chatterbox#handle_notice is deprecated and will be removed from Chatterbox 1.0. Call Chatterbox#notify instead."
  deprecate(warning, caller)
  notify(message)
end

#loggerObject

Retrieve (lazily loaded) logger; defaults to a nil Logger


36
37
38
# File 'lib/chatterbox.rb', line 36

def logger
  @logger ||= Logger.new(nil)
end

#logger=(logger) ⇒ Object

Set default logger for Chatterbox to use; mostly for development and debugging purposes


41
42
43
# File 'lib/chatterbox.rb', line 41

def logger=(logger)
  @logger = logger
end

#notify(message) ⇒ Object

Send a notification with Chatterbox Returns the message itself

message is an options hash that allows the following options:

:summary - The summary of the message - required. If your service only supports

'short' notifications, like Twitter, this is generally what you should send.

:body - The body of the message - this may not be used if the service you are using

doesn't support 'bodies' -- for example, Twitter.

:config - The configuration settings for the different services the notification should use.

See the individual services you are using for what configuration options should be used.

15
16
17
18
# File 'lib/chatterbox.rb', line 15

def notify(message)
  publish_notice(message)
  message
end

#publish_notice(message) ⇒ Object


20
21
22
# File 'lib/chatterbox.rb', line 20

def publish_notice(message)
  Publishers.publishers.each { |p| p.call(message.with_indifferent_access) }
end

#register(&blk) ⇒ Object

Register a service for sending notifications

Example:
Chatterbox::Publishers.register do |notice|
  Chatterbox::Services::Email.deliver(notice)
 end

52
53
54
# File 'lib/chatterbox.rb', line 52

def register(&blk)
  Publishers.register(&blk)
end