Class: ActivityNotification::OptionalTarget::Slack
- Defined in:
- lib/activity_notification/optional_targets/slack.rb
Overview
Optional target implementation for Slack.
Instance Method Summary collapse
-
#initialize_target(options = {}) ⇒ Object
Initialize method to prepare Slack::Notifier.
-
#notify(notification, options = {}) ⇒ Object
Publishes notification message to Slack.
Methods inherited from Base
#initialize, #to_optional_target_name
Constructor Details
This class inherits a constructor from ActivityNotification::OptionalTarget::Base
Instance Method Details
#initialize_target(options = {}) ⇒ Object
Initialize method to prepare Slack::Notifier
12 13 14 15 |
# File 'lib/activity_notification/optional_targets/slack.rb', line 12 def initialize_target( = {}) @target_username = .delete(:target_username) @notifier = ::Slack::Notifier.new(.delete(:webhook_url), ) end |
#notify(notification, options = {}) ⇒ Object
Publishes notification message to Slack
27 28 29 30 |
# File 'lib/activity_notification/optional_targets/slack.rb', line 27 def notify(notification, = {}) target_username = notification.target.resolve_value(.delete(:target_username) || @target_username) @notifier.ping((notification, .merge(assignment: { target_username: target_username }))) end |