class Noticed::DeliveryMethods::Database

Public Class Methods

validate!(options) click to toggle source
# File lib/noticed/delivery_methods/database.rb, line 9
def self.validate!(options)
  super

  # Must be executed right away so the other deliveries can access the db record
  raise ArgumentError, "database delivery cannot be delayed" if options.key?(:delay)
end

Public Instance Methods

deliver() click to toggle source

Must return the database record

# File lib/noticed/delivery_methods/database.rb, line 5
def deliver
  recipient.send(association_name).create!(attributes)
end

Private Instance Methods

association_name() click to toggle source
# File lib/noticed/delivery_methods/database.rb, line 18
def association_name
  options[:association] || :notifications
end
attributes() click to toggle source
# File lib/noticed/delivery_methods/database.rb, line 22
def attributes
  if (method = options[:format])
    notification.send(method)
  else
    {
      type: notification.class.name,
      params: notification.params
    }
  end
end