Sha256: 1653108825234fc18403da621b6d6ae4e0efd60ab48401fc2bec4fe3ba32d12c

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module Devise
  module Models
    module SlackNotifiable
      extend ActiveSupport::Concern

      included do
        after_create :registration_notification

        protected

        def after_confirmation
          confirmation_notification

          super
        end

        def confirmation_notification
          return unless DeviseSlackNotifiable.configuration.confirmation_message_enabled

          send_slack_notification(
            DeviseSlackNotifiable.configuration.confirmation_message_formatter
          )
        end

        def registration_notification
          send_slack_notification(
            DeviseSlackNotifiable.configuration.registration_message_formatter
          )
        end

        private

        def send_slack_notification(formatter)
          notifier = DeviseSlackNotifiable::Notifier.new
          notifier.send_message(self, formatter)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_slack_notifiable-0.1.0 lib/devise/models/slack_notifiable.rb