Class: QueryTrack::Notifications::Slack
- Inherits:
-
Object
- Object
- QueryTrack::Notifications::Slack
- Defined in:
- lib/query_track/notifications/slack.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#webhook_url ⇒ Object
readonly
Returns the value of attribute webhook_url.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(code, duration) ⇒ Slack
constructor
A new instance of Slack.
Constructor Details
#initialize(code, duration) ⇒ Slack
Returns a new instance of Slack.
6 7 8 9 10 |
# File 'lib/query_track/notifications/slack.rb', line 6 def initialize(code, duration) @code = code.strip @duration = duration @webhook_url = QueryTrack::Settings.config.notifications.slack end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/query_track/notifications/slack.rb', line 4 def code @code end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
4 5 6 |
# File 'lib/query_track/notifications/slack.rb', line 4 def duration @duration end |
#webhook_url ⇒ Object (readonly)
Returns the value of attribute webhook_url.
4 5 6 |
# File 'lib/query_track/notifications/slack.rb', line 4 def webhook_url @webhook_url end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/query_track/notifications/slack.rb', line 12 def call return if webhook_url.nil? || webhook_url.empty? slack_hook = SlackHook::Incoming.new(webhook_url) trace = QueryTrack::Trace.new(caller).call payload = { blocks: blocks(trace) } Thread.new { slack_hook.post(payload) } end |