Class: Slack::Notifier
- Inherits:
-
Object
- Object
- Slack::Notifier
- Defined in:
- lib/slack-notifier.rb,
lib/slack-notifier/version.rb,
lib/slack-notifier/http_post.rb,
lib/slack-notifier/link_formatter.rb
Defined Under Namespace
Classes: HTTPPost, LinkFormatter
Constant Summary collapse
- VERSION =
"0.5.0"
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.
-
#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, hook_name = default_hook_name, default_payload = {}) ⇒ Notifier
constructor
A new instance of Notifier.
- #ping(message, options = {}) ⇒ Object
- #username ⇒ Object
- #username=(username) ⇒ Object
Constructor Details
#initialize(team, token, hook_name = default_hook_name, default_payload = {}) ⇒ Notifier
Returns a new instance of Notifier.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/slack-notifier.rb', line 12 def initialize team, token, hook_name=default_hook_name, default_payload={} @team = team @token = token if hook_name.is_a? Hash @hook_name = default_hook_name @default_payload = hook_name else @hook_name = hook_name @default_payload = default_payload end 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 |
#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
32 33 34 |
# File 'lib/slack-notifier.rb', line 32 def channel default_payload[:channel] end |
#channel=(channel) ⇒ Object
36 37 38 |
# File 'lib/slack-notifier.rb', line 36 def channel= channel default_payload[:channel] = channel end |
#ping(message, options = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/slack-notifier.rb', line 25 def ping , ={} = LinkFormatter.format() payload = { text: }.merge(default_payload).merge() HTTPPost.to endpoint, payload: payload.to_json end |
#username ⇒ Object
40 41 42 |
# File 'lib/slack-notifier.rb', line 40 def username default_payload[:username] end |
#username=(username) ⇒ Object
44 45 46 |
# File 'lib/slack-notifier.rb', line 44 def username= username default_payload[:username] = username end |