Module: Hertz::Notifiable

Defined in:
lib/hertz/notifiable.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hertz/notifiable.rb', line 4

def self.included(base)
  base.class_eval <<-RUBY
    has_many :notifications,
      class_name: 'Hertz::Notification',
      as: :receiver,
      inverse_of: :receiver,
      dependent: :destroy

    def notify(notification)
      notifications << notification
    end
  RUBY
end