class SlackMessaging::NotifySlack

Attributes

channel[RW]
icon_emoji[RW]
icon_url[RW]
text[RW]
username[RW]
webhook_url[RW]

Public Class Methods

new(text) click to toggle source
# File lib/slack_messaging/notify_slack.rb, line 7
def initialize(text)
  self.text = text
  self.channel = SlackMessaging::Config.slack[:channel]
  self.webhook_url = SlackMessaging::Config.slack[:webhook_url]
  self.username = SlackMessaging::Config.slack[:username] || 'MessageMe'
  self.icon_emoji = SlackMessaging::Config.slack[:icon_emoji] || ':mailbox_with_mail'
end

Public Instance Methods

perform() click to toggle source
# File lib/slack_messaging/notify_slack.rb, line 15
def perform
  options = {
    channel: channel,
    username: username,
    icon_emoji: icon_emoji,
    text: text
  }

  HTTParty.post(webhook_url, body: options.to_json)
end