Class: Newshound::SlackNotifier
- Inherits:
-
Object
- Object
- Newshound::SlackNotifier
- Defined in:
- lib/newshound/slack_notifier.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Instance Method Summary collapse
-
#initialize(configuration: nil, logger: nil, transport: nil) ⇒ SlackNotifier
constructor
A new instance of SlackNotifier.
- #post(message) ⇒ Object
Constructor Details
#initialize(configuration: nil, logger: nil, transport: nil) ⇒ SlackNotifier
Returns a new instance of SlackNotifier.
9 10 11 12 13 |
# File 'lib/newshound/slack_notifier.rb', line 9 def initialize(configuration: nil, logger: nil, transport: nil) @configuration = configuration || Newshound.configuration @logger = logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT)) @transport = transport || build_transport end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/newshound/slack_notifier.rb', line 7 def configuration @configuration end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/newshound/slack_notifier.rb', line 7 def logger @logger end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
7 8 9 |
# File 'lib/newshound/slack_notifier.rb', line 7 def transport @transport end |
Instance Method Details
#post(message) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/newshound/slack_notifier.rb', line 15 def post() return unless configuration.valid? transport.deliver() rescue StandardError => e logger.error "Newshound: Failed to send notification: #{e.message}" end |