Class: WatchDoge::Notification::SlackWebhook

Inherits:
Object
  • Object
show all
Defined in:
lib/watchdoge/notification/slack_webhook.rb

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ SlackWebhook

Returns a new instance of SlackWebhook.



4
5
6
7
8
# File 'lib/watchdoge/notification/slack_webhook.rb', line 4

def initialize opt
  super

  @incoming_url = opt[:incoming_url]
end

Instance Method Details

#flushObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/watchdoge/notification/slack_webhook.rb', line 10

def flush
  @message_queue.each do |message|
    body = slack_body(message).to_json
    Net::HTTP.post URI(@incoming_url),
                   body,
                   "Content-Type" => "application/json"
  end

  @message_queue = []
end