Module: Slackr::IncomingWebhook
- Extended by:
- IncomingWebhook
- Included in:
- IncomingWebhook
- Defined in:
- lib/slackr/webhooks/incoming.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#say(connection, text = "", options = {}) ⇒ Object
{ :formatter => [BasicFormatter, LinkFormatter, AttachmentFormatter] }.
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
10 11 12 |
# File 'lib/slackr/webhooks/incoming.rb', line 10 def connection @connection end |
Instance Method Details
#say(connection, text = "", options = {}) ⇒ Object
{ :formatter => [BasicFormatter, LinkFormatter, AttachmentFormatter] }
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/slackr/webhooks/incoming.rb', line 15 def say(connection, text="", ={}) @connection = connection #formatter = options[:formatter] || BasicFormatter #text = format_text(formatter, text) #TODO: fix law of demeter violations request = Net::HTTP::Post.new(service_url) request.body = (text, ) response = connection.http_request(request) if response.code != "200" raise Slackr::ServiceError, "Slack.com - #{response.code} - #{response.body}" end end |