docbrown/app/services/slack/announcer.rb
Anna Buianova 784afdf41e
Routine rubocop fixes (#19254)
* Rubocop fixes

* Rubocop fixes

* Fixed rubocop violation

* Fixed policies rubocop violations

* More rubocop fixes
2023-03-24 14:37:44 +03:00

31 lines
692 B
Ruby

module Slack
# a thin wrapper on Slack::Notifier
# for additional options, see https://github.com/stevenosloan/slack-notifier
class Announcer
def self.call(...)
new(...).call
end
def initialize(message:, channel:, username:, icon_emoji:)
@message = message
@channel = channel
@username = username
@icon_emoji = icon_emoji
end
def call
return if [message, channel, username, icon_emoji].any?(&:blank?)
SlackClient.ping(
message,
channel: channel,
username: username,
icon_emoji: icon_emoji,
)
end
private
attr_reader :message, :channel, :username, :icon_emoji
end
end