Class: Slack::Notifier
- Inherits:
-
Object
- Object
- Slack::Notifier
- Defined in:
- lib/slack-notifier.rb,
lib/slack-notifier/version.rb,
lib/slack-notifier/link_formatter.rb,
lib/slack-notifier/default_http_client.rb
Defined Under Namespace
Classes: DefaultHTTPClient, LinkFormatter
Constant Summary collapse
- VERSION =
"0.6.1"
Instance Attribute Summary collapse
-
#default_payload ⇒ Object
readonly
Returns the value of attribute default_payload.
-
#hook_name ⇒ Object
readonly
Returns the value of attribute hook_name.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #channel ⇒ Object
- #channel=(channel) ⇒ Object
-
#initialize(team, token, options = {}) ⇒ Notifier
constructor
hook_name=default_hook_name, default_payload={}.
- #ping(message, options = {}) ⇒ Object
- #username ⇒ Object
- #username=(username) ⇒ Object
Constructor Details
#initialize(team, token, options = {}) ⇒ Notifier
hook_name=default_hook_name, default_payload={}
13 14 15 16 17 18 19 |
# File 'lib/slack-notifier.rb', line 13 def initialize team, token, ={} # hook_name=default_hook_name, default_payload={} @team = team @token = token @http_client = .delete(:http_client) || DefaultHTTPClient @hook_name = .delete(:hook_name) || default_hook_name @default_payload = end |
Instance Attribute Details
#default_payload ⇒ Object (readonly)
Returns the value of attribute default_payload.
10 11 12 |
# File 'lib/slack-notifier.rb', line 10 def default_payload @default_payload end |
#hook_name ⇒ Object (readonly)
Returns the value of attribute hook_name.
10 11 12 |
# File 'lib/slack-notifier.rb', line 10 def hook_name @hook_name end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
10 11 12 |
# File 'lib/slack-notifier.rb', line 10 def http_client @http_client end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
10 11 12 |
# File 'lib/slack-notifier.rb', line 10 def team @team end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
10 11 12 |
# File 'lib/slack-notifier.rb', line 10 def token @token end |
Instance Method Details
#channel ⇒ Object
29 30 31 |
# File 'lib/slack-notifier.rb', line 29 def channel default_payload[:channel] end |
#channel=(channel) ⇒ Object
33 34 35 |
# File 'lib/slack-notifier.rb', line 33 def channel= channel default_payload[:channel] = channel end |
#ping(message, options = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/slack-notifier.rb', line 21 def ping , ={} = LinkFormatter.format() payload = { text: }.merge(default_payload).merge() http_client.post endpoint, payload: payload.to_json end |
#username ⇒ Object
37 38 39 |
# File 'lib/slack-notifier.rb', line 37 def username default_payload[:username] end |
#username=(username) ⇒ Object
41 42 43 |
# File 'lib/slack-notifier.rb', line 41 def username= username default_payload[:username] = username end |