class Slack::Payload
Attributes
attachments[RW]
channel[RW]
icon_url[RW]
text[RW]
token[RW]
username[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/slack/payload.rb, line 5 def initialize(options = {}) @username = options[:username] || Slack.username @channel = options[:channel] || Slack.default_channel @text = options[:text] @token = options[:token] @icon_url = options[:icon_url] @attachments = options[:attachments] unless channel[0] =~ /^(#|@)/ @channel = "##{@channel}" end end
Public Instance Methods
to_hash()
click to toggle source
# File lib/slack/payload.rb, line 18 def to_hash hash = { text: text, username: username, channel: channel, token: token, icon_url: icon_url, attachments: attachments.to_json } hash.delete_if { |_,v| v.nil? || v == "null"} end