Sha256: 58277e503cb8381fccbe67175b5dfe7e82e0e5fb7e1e47ce39368fe3bc8a75e0

Contents?: true

Size: 649 Bytes

Versions: 1

Compression:

Stored size: 649 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-1.2.6 lib/notification_handler/target.rb