Module: Harbinger
- Defined in:
- lib/harbinger.rb,
lib/harbinger/engine.rb,
lib/harbinger/message.rb,
lib/harbinger/version.rb,
lib/harbinger/channels.rb,
lib/harbinger/reporters.rb,
lib/harbinger/exceptions.rb,
lib/harbinger/configuration.rb,
app/helpers/harbinger/application_helper.rb,
lib/harbinger/reporters/request_reporter.rb,
app/controllers/harbinger/messages_controller.rb,
app/models/harbinger/database_channel_message.rb,
app/controllers/harbinger/application_controller.rb,
lib/generators/harbinger/install/install_generator.rb,
app/models/harbinger/database_channel_message_element.rb
Defined Under Namespace
Modules: ApplicationHelper, Channels, Reporters
Classes: ApplicationController, Configuration, ConfigurationError, DatabaseChannelMessage, DatabaseChannelMessageElement, Engine, InstallGenerator, Message, MessagesController
Constant Summary
collapse
- VERSION =
"0.2.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
13
14
15
|
# File 'lib/harbinger.rb', line 13
def configuration
@configuration ||= Configuration.new
end
|
Class Method Details
.build_message(options = {}) ⇒ Object
Responsible for building a :message from the various :reporters.
53
54
55
56
57
58
59
|
# File 'lib/harbinger.rb', line 53
def build_message(options = {})
reporters = Array(options.fetch(:reporters)).flatten.compact
message = options.fetch(:message) { default_message }
reporters.each { |context| reporter_for(context).accept(message) }
message
end
|
.call(options) ⇒ Object
Responsible for building a :message from the various :reporters and then delivering the :message to the appropriate :channels.
39
40
41
42
|
# File 'lib/harbinger.rb', line 39
def call(options)
message = build_message(options)
deliver_message(message, options)
end
|
22
23
24
|
# File 'lib/harbinger.rb', line 22
def configure
yield(configuration)
end
|
.database_storage ⇒ Object
106
107
108
|
# File 'lib/harbinger.rb', line 106
def database_storage
configuration.database_storage
end
|
.default_channels ⇒ Object
96
97
98
|
# File 'lib/harbinger.rb', line 96
def default_channels
configuration.default_channels
end
|
.deliver_message(message, options = {}) ⇒ Object
Responsible for delivering a :message to the appropriate :channels.
70
71
72
73
74
75
76
77
|
# File 'lib/harbinger.rb', line 70
def deliver_message(message, options = {})
channels = options.fetch(:channels) { default_channels }
Array(channels).flatten.compact.each do |channel_name|
channel = channel_for(channel_name)
channel.deliver(message)
end
true
end
|
.logger ⇒ Object
101
102
103
|
# File 'lib/harbinger.rb', line 101
def logger
configuration.logger
end
|