Module: Notifications::ClassMethods
- Defined in:
- app/models/concerns/notifications.rb
Instance Method Summary collapse
-
#for_group(group, args: [], attrs: {}) ⇒ Object
we're overriding
for_group
here because we need to reference our Notification class that inherits from NotificationHandler::Notification, otherwise, our subclass's methods don't get called.
Instance Method Details
#for_group(group, args: [], attrs: {}) ⇒ Object
we're overriding for_group
here because we need to reference
our Notification class that inherits from NotificationHandler::Notification,
otherwise, our subclass's methods don't get called.
10 11 12 13 14 15 16 17 |
# File 'app/models/concerns/notifications.rb', line 10 def for_group(group, args: [], attrs: {}) return if group.nil? target_scope = NotificationHandler::Group.find_by_name!(group).target_scope target_scope.call(*args)&.map do |target| Notification.create(attrs.merge(target: target)) end end |