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.
- :batch_email_allowed
- Whether activity_notification sends batch 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 batch notification email, both of batch_email_allowed and subscription_allowed options must return true (not nil) in target model. This can be also configured default option in initializer.
- :subscription_allowed
- Whether activity_notification manages subscriptions of 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. This can be also configured default option in initializer.
- :action_cable_allowed
- Whether activity_notification publishes WebSocket notifications using ActionCable 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 ActionCable for notifications, action_cable_enabled option must return true (not nil) in both of notifiable and target model. This can be also configured default option in initializer.
- :action_cable_with_devise
- Whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise. 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 ActionCable for notifications, also action_cable_enabled option must return true (not nil) in the target model.
- :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 in routes.rb
- Integrated resource with devise authentication.
This parameter is a optional since
- :current_devise_target
- Current authenticated target by devise authentication.
This parameter is a optional since
current_<devise_resource_name>is used as default value. In addition, this parameter is only needed when :devise_default_route in your route.rb is enabled. You also have to configure routing for devise in routes.rb
- Current authenticated target by devise authentication.
This parameter is a optional since
- :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
- Printable notification target name.
This parameter is a optional since
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/activity_notification/roles/acts_as_target.rb', line 185 def acts_as_target( = {}) include Target [:printable_notification_target_name] ||= .delete(:printable_name) [:batch_notification_email_allowed] ||= .delete(:batch_email_allowed) acts_as_params = set_acts_as_parameters([:email, :email_allowed, :subscription_allowed, :action_cable_allowed, :action_cable_with_devise, :devise_resource, :current_devise_target], , "notification_") .merge set_acts_as_parameters([:batch_notification_email_allowed, :printable_notification_target_name], ) include Subscriber if subscription_enabled? acts_as_params end |
.available_target_options ⇒ Array<Symbol>
Returns array of available target options in acts_as_target.
199 200 201 |
# File 'lib/activity_notification/roles/acts_as_target.rb', line 199 def [:email, :email_allowed, :batch_email_allowed, :subscription_allowed, :action_cable_enabled, :action_cable_with_devise, :devise_resource, :printable_notification_target_name, :printable_name].freeze end |