Module: UserNotification::ActsAsNotifiable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/user_notification/roles/acts_as_notifiable.rb
Overview
Main module extending classes we want to keep track of.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#notification(options = {}) ⇒ nil
A shortcut method for setting custom key, owner and parameters of Notification in one line.
Instance Method Details
#notification(options = {}) ⇒ nil
A shortcut method for setting custom key, owner and parameters of Notification in one line. Accepts a hash with 3 keys: :key, :owner, :params. You can specify all of them or just the ones you want to overwrite.
Options
- :key
- :owner
- :params
- :recipient
-
Set the recipient for this notification. Useful for private notifications, which should only be visible to a certain user. See Common#notification_recipient.
30 31 32 33 34 35 36 37 38 |
# File 'lib/user_notification/roles/acts_as_notifiable.rb', line 30 def notification( = {}) rest = .clone self.notification_key = rest.delete(:key) if rest[:key] self.notification_owner = rest.delete(:owner) if rest[:owner] self.notification_params = rest.delete(:params) if rest[:params] self.notification_recipient = rest.delete(:recipient) if rest[:recipient] self.notification_custom_fields = rest if rest.count > 0 nil end |