Module: Notifi::Subscribable
- Defined in:
- lib/notifi/subscribable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/notifi/subscribable.rb', line 3 def self.included(base) base.has_many :subscriptions, as: :subscribable, class_name: Subscription.name, dependent: :destroy, inverse_of: :subscribable base.has_many :notifications, as: :subscribable, class_name: Notification.name, dependent: :destroy, inverse_of: :subscribable end |
Instance Method Details
#notify(event = :default, notifier: nil, set: {}) ⇒ Object
15 16 17 |
# File 'lib/notifi/subscribable.rb', line 15 def notify(event=:default, notifier: nil, set: {}) self.subscriptions.each { |s| s.notify(event, notifier: notifier, set: set) } end |