Module: ActivityNotification::ActsAsTarget
- Extended by:
- ActiveSupport::Concern
- Included in:
- Models
- Defined in:
- lib/activity_notification/roles/acts_as_target.rb
Overview
Manages to add all required configurations to target models of notification.
Class Method Summary collapse
-
.acts_as_target(options = {}) ⇒ Hash
(also: acts_as_notification_target)
Adds required configurations to notifiable models.
-
.available_target_options ⇒ Array<Symbol>
Returns array of available target options in acts_as_target.
Class Method Details
.acts_as_target(options = {}) ⇒ Hash Also known as: acts_as_notification_target
Adds required configurations to notifiable models.
Parameters:
-
:email
-
Email address to send notification email. This is a necessary option when you enables email notification.
-
-
:email_allowed
-
Whether activity_notification sends notification email to this target. Specified method or symbol is expected to return true (not nil) or false (nil). This parameter is a optional since default value is false. To use notification email, email_allowed option must return true (not nil) in both of notifiable and target model. This can be also configured default option in initializer.
-
-
:devise_resource
-
Integrated resource with devise authentication. This parameter is a optional since
selfis used as default value. You also have to configure routing for devise inroutes.rb
-
-
:printable_name or :printable_notification_target_name
-
Printable notification target name. This parameter is a optional since
ActivityNotification::Common.printable_nameis used as default value. :printable_name is the same option as :printable_notification_target_name
-
94 95 96 97 98 99 100 101 |
# File 'lib/activity_notification/roles/acts_as_target.rb', line 94 def acts_as_target( = {}) include Target [:printable_notification_target_name] ||= .delete(:printable_name) [:batch_notification_email_allowed] ||= .delete(:batch_email_allowed) set_acts_as_parameters([:email, :email_allowed, :devise_resource], , "notification_") .merge set_acts_as_parameters([:batch_notification_email_allowed, :printable_notification_target_name], ) end |
.available_target_options ⇒ Array<Symbol>
Returns array of available target options in acts_as_target.
106 107 108 |
# File 'lib/activity_notification/roles/acts_as_target.rb', line 106 def [:email, :email_allowed, :batch_email_allowed, :devise_resource, :printable_notification_target_name, :printable_name].freeze end |