Sha256: a4bd0f98bb9af46f3c3f77864f00c9b9aa26a8e182146901b55a7f560af61aef

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module NotificationHandler
  module Target
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def notification_target
        has_many :notifications, as: :target, dependent: :destroy
        include NotificationHandler::Target::InstanceMethods

        include NotificationSettings::Target if defined?(NotificationSettings)
        return unless defined?(NotificationSettings)

        include NotificationSettings::Subscriber
      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-2.0.0 lib/notification_handler/target.rb