You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mail_notification.rb
    path of file: ./repos/foreman/app/models/mail_notifications
    
    the code of the file until where you have to start completion: class MailNotification < ApplicationRecord
  include Authorizable

  INTERVALS = [N_("Daily"), N_("Weekly"), N_("Monthly")]
  SUBSCRIPTION_TYPES = %w(alert report)

  has_many :user_mail_notifications, :dependent => :destroy
  has_many :users, :through => :user_mail_notifications

  scoped_search :on => :id, :comple
    
  def deliver(*args)
    # args can be anything really, treat it carefully
    # handle args=[.., :users => [..]] specially and instantiate a single mailer per user, with :user set on each
    if args.last.is_a?(Hash) && args.last.has_key?(:users)
      options = args.pop
      options.delete(:users).each do |user|
        mailer.constantize.send(method, *args, options.merge(:user => user)).deliver_now
      end
    else
      mailer.constantize.send(method, *args).deliver_now
    end