Class: ForemanSlack::SlackNotify

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_slack/slack_notify.rb

Instance Method Summary collapse

Constructor Details

#initializeSlackNotify

Returns a new instance of SlackNotify.



4
5
6
7
8
9
# File 'app/services/foreman_slack/slack_notify.rb', line 4

def initialize
  @webhook = Setting[:slack_webhook]
  @channel = Setting[:slack_channel] || '#general' #each Slack team has a general channel
  @username = Setting[:slack_username] || 'foreman'
  @notifier = ::Slack::Notifier.new(@webhook, :channel => @channel, :username => @username) if valid_webhook?
end

Instance Method Details

#notify(message) ⇒ Object



11
12
13
# File 'app/services/foreman_slack/slack_notify.rb', line 11

def notify(message)
  @notifier.ping(message) if @notifier
end