Class: ActivityNotification::OptionalTarget::Slack
- Defined in:
- lib/activity_notification/optional_targets/slack.rb
Overview
Optional target implementation for Slack.
Instance Attribute Summary
Attributes inherited from Base
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( = {}) @slack_name = .delete(:slack_name) @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, = {}) slack_name = notification.target.resolve_value(.delete(:slack_name) || @slack_name) @notifier.ping((notification, .merge(assignment: { slack_name: slack_name }))) end |