Method: ActivityNotification::NotificationApi.notify_to
- Defined in:
- lib/activity_notification/apis/notification_api.rb
.notify_to(target, notifiable, options = {}) ⇒ Notification Also known as: notify_now_to
Generates notifications to one target.
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/activity_notification/apis/notification_api.rb', line 340 def notify_to(target, notifiable, = {}) if [:notify_later] notify_later_to(target, notifiable, ) else send_email = .has_key?(:send_email) ? [:send_email] : true send_later = .has_key?(:send_later) ? [:send_later] : true publish_optional_targets = .has_key?(:publish_optional_targets) ? [:publish_optional_targets] : true # Generate notification notification = generate_notification(target, notifiable, ) # Send notification email if notification.present? && send_email notification.send_notification_email({ send_later: send_later }) end # Publish to optional targets if notification.present? && publish_optional_targets notification.publish_to_optional_targets([:optional_targets] || {}) end # Return generated notification notification end end |