Class: HasHelpers::SlackNotifier
- Inherits:
-
Object
- Object
- HasHelpers::SlackNotifier
- Defined in:
- lib/has_helpers/utils/slack_notifier.rb
Class Attribute Summary collapse
-
.default_channel_resolver ⇒ Object
Returns the value of attribute default_channel_resolver.
Class Method Summary collapse
- .default_channel ⇒ Object
-
.notify(message, channel: default_channel) ⇒ Object
CLASS METHODS ######.
Instance Method Summary collapse
-
#notify(message, channel:) ⇒ Object
INSTANCE METHODS ######.
Class Attribute Details
.default_channel_resolver ⇒ Object
Returns the value of attribute default_channel_resolver.
13 14 15 |
# File 'lib/has_helpers/utils/slack_notifier.rb', line 13 def default_channel_resolver @default_channel_resolver end |
Class Method Details
.default_channel ⇒ Object
16 17 18 19 |
# File 'lib/has_helpers/utils/slack_notifier.rb', line 16 def self.default_channel return nil if ::HasUtils::Env.test? || ::HasUtils::Env.development? default_channel_resolver&.call end |
.notify(message, channel: default_channel) ⇒ Object
CLASS METHODS ######
7 8 9 10 |
# File 'lib/has_helpers/utils/slack_notifier.rb', line 7 def self.notify(, channel: default_channel) @default_notifier ||= HasHelpers::SlackNotifier.new @default_notifier.notify(, channel: channel) end |
Instance Method Details
#notify(message, channel:) ⇒ Object
INSTANCE METHODS ######
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/has_helpers/utils/slack_notifier.rb', line 23 def notify(, channel:) if channel.nil? puts return end begin slack_client.chat_postMessage(channel: channel, text: , as_user: true, mrkdwn: true, link_names: true) rescue => e ::Rails.logger.warn("Unable to send slack notification: #{e.}") end end |