Module: MailyHerald::ModelExtensions

Defined in:
lib/maily_herald/model_extensions.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/maily_herald/model_extensions.rb', line 3

def self.included(base)
  unloadable
  base.class_eval do
    has_many    :maily_herald_subscriptions,       as: :entity, class_name: "MailyHerald::Subscription", dependent: :destroy
    has_many    :maily_herald_logs,                as: :entity, class_name: "MailyHerald::Log"

    after_destroy do
      self.maily_herald_logs.scheduled.destroy_all
    end
  end
end