Class: DeviseSlackNotifiable::Notifier
- Inherits:
-
Object
- Object
- DeviseSlackNotifiable::Notifier
- Defined in:
- lib/devise_slack_notifiable/notifier.rb
Overview
Module <-> Slack communication layer and payload builder
Instance Method Summary collapse
-
#initialize ⇒ Notifier
constructor
DeviseSlackNotifiable::Notifier constructor.
-
#send_message(entity, message_formatter) ⇒ Object
Sends slack message.
Constructor Details
#initialize ⇒ Notifier
DeviseSlackNotifiable::Notifier constructor.
Creates Slack::Notifier instance
13 14 15 16 17 18 19 |
# File 'lib/devise_slack_notifiable/notifier.rb', line 13 def initialize return unless enabled? raise DeviseSlackNotifiable::Errors::Configuration, 'Missing Slack Webhook URL' unless webhook @client = Slack::Notifier.new(webhook) end |
Instance Method Details
#send_message(entity, message_formatter) ⇒ Object
Sends slack message
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/devise_slack_notifiable/notifier.rb', line 25 def (entity, ) return true unless enabled? @client.ping( formatter( .call(entity), entity ) ) end |