Sha256: 485ef29f54380d3c32627462610c88839b0e78e85118942b4935bd7e186726e3

Contents?: true

Size: 728 Bytes

Versions: 1

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module NotificationHandler
  module Target
    extend ActiveSupport::Concern

    included do
      def self.notification_target
        has_many :notifications, as: :target, dependent: :destroy
        include NotificationHandler::Target::InstanceMethods

        include NotificationSettings::Target if defined?(NotificationSettings)
        # rubocop:disable Style/GuardClause
        if defined?(NotificationSettings)
          include NotificationSettings::Subscriber
        end
        # rubocop:enable Style/GuardClause
      end
    end

    module InstanceMethods
      def notify(options = {})
        notifications.create(options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notification-handler-3.0.2 lib/notification_handler/target.rb