Class: ActivityNotification::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/activity_notification/config.rb

Overview

Class used to initialize configuration object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Initialize configuration for ActivityNotification. These configuration can be overridden in initializer.



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/activity_notification/config.rb', line 255

def initialize
  @enabled                                  = true
  @orm                                      = :active_record
  @notification_table_name                  = 'notifications'
  @subscription_table_name                  = 'subscriptions'
  @email_enabled                            = false
  @subscription_enabled                     = false
  @subscribe_as_default                     = true
  @subscribe_to_email_as_default            = nil
  @subscribe_to_optional_targets_as_default = nil
  @mailer_sender                            = nil
  @mailer_cc                                = nil
  @mailer_attachments                       = nil
  @mailer                                   = 'ActivityNotification::Mailer'
  @parent_mailer                            = 'ActionMailer::Base'
  @parent_job                               = 'ActiveJob::Base'
  @parent_controller                        = 'ApplicationController'
  @parent_channel                           = 'ActionCable::Channel::Base'
  @mailer_templates_dir                     = 'activity_notification/mailer'
  @opened_index_limit                       = 10
  @active_job_queue                         = :activity_notification
  @composite_key_delimiter                  = '#'
  @store_with_associated_records            = false
  @action_cable_enabled                     = false
  @action_cable_api_enabled                 = false
  @action_cable_with_devise                 = false
  @notification_channel_prefix              = 'activity_notification_channel'
  @notification_api_channel_prefix          = 'activity_notification_api_channel'
  @rescue_optional_target_errors            = true
  @restrict_api_response_fields             = false
end

Instance Attribute Details

#action_cable_api_enabledBoolean #action_cable_api_enabled=(value) ⇒ Boolean

Overloads:

  • #action_cable_api_enabledBoolean

    Returns whether WebSocket API subscription using ActionCable is enabled

    Returns:

    • (Boolean)

      Whether WebSocket API subscription using ActionCable is enabled.

  • #action_cable_api_enabled=(value) ⇒ Boolean

    Sets whether WebSocket API subscription using ActionCable is enabled

    Parameters:

    • action_cable_enabled (Boolean)

      The new action_cable_api_enabled

    Returns:

    • (Boolean)

      Whether WebSocket API subscription using ActionCable is enabled.



205
206
207
# File 'lib/activity_notification/config.rb', line 205

def action_cable_api_enabled
  @action_cable_api_enabled
end

#action_cable_enabledBoolean #action_cable_enabled=(value) ⇒ Boolean

Overloads:

  • #action_cable_enabledBoolean

    Returns whether WebSocket subscription using ActionCable is enabled

    Returns:

    • (Boolean)

      Whether WebSocket subscription using ActionCable is enabled.

  • #action_cable_enabled=(value) ⇒ Boolean

    Sets whether WebSocket subscription using ActionCable is enabled

    Parameters:

    • action_cable_enabled (Boolean)

      The new action_cable_enabled

    Returns:

    • (Boolean)

      Whether WebSocket subscription using ActionCable is enabled.



196
197
198
# File 'lib/activity_notification/config.rb', line 196

def action_cable_enabled
  @action_cable_enabled
end

#action_cable_with_deviseBoolean #action_cable_with_devise=(value) ⇒ Boolean

Overloads:

  • #action_cable_with_deviseBoolean

    Returns whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise

    Returns:

    • (Boolean)

      Whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.

  • #action_cable_with_devise=(value) ⇒ Boolean

    Sets whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise

    Parameters:

    • action_cable_with_devise (Boolean)

      The new action_cable_with_devise

    Returns:

    • (Boolean)

      Whether activity_notification publishes WebSocket notifications using ActionCable only to authenticated target with Devise.



214
215
216
# File 'lib/activity_notification/config.rb', line 214

def action_cable_with_devise
  @action_cable_with_devise
end

#active_job_queueSymbol #active_job_queue=(value) ⇒ Symbol

Overloads:

  • #active_job_queueSymbol

    Returns ActiveJob queue name for delayed notifications

    Returns:

    • (Symbol)

      ActiveJob queue name for delayed notifications.

  • #active_job_queue=(value) ⇒ Symbol

    Sets ActiveJob queue name for delayed notifications

    Parameters:

    • active_job_queue (Symbol)

      The new active_job_queue

    Returns:

    • (Symbol)

      ActiveJob queue name for delayed notifications.



173
174
175
# File 'lib/activity_notification/config.rb', line 173

def active_job_queue
  @active_job_queue
end

#composite_key_delimiterString #composite_key_delimiter=(value) ⇒ Symbol

Overloads:

  • #composite_key_delimiterString

    Returns Delimiter of composite key for DynamoDB

    Returns:

    • (String)

      Delimiter of composite key for DynamoDB.

  • #composite_key_delimiter=(value) ⇒ Symbol

    Sets delimiter of composite key for DynamoDB

    Parameters:

    • composite_key_delimiter (Symbol)

      The new delimiter of composite key for DynamoDB

    Returns:

    • (Symbol)

      Delimiter of composite key for DynamoDB.



182
183
184
# File 'lib/activity_notification/config.rb', line 182

def composite_key_delimiter
  @composite_key_delimiter
end

#email_enabledBoolean #email_enabled=(value) ⇒ Boolean

Overloads:

  • #email_enabledBoolean

    Returns whether activity_notification sends notification email

    Returns:

    • (Boolean)

      Whether activity_notification sends notification email.

  • #email_enabled=(value) ⇒ Boolean

    Sets whether activity_notification sends notification email

    Parameters:

    • email_enabled (Boolean)

      The new email_enabled

    Returns:

    • (Boolean)

      Whether activity_notification sends notification email.



44
45
46
# File 'lib/activity_notification/config.rb', line 44

def email_enabled
  @email_enabled
end

#enabledBoolean #enabled=(value) ⇒ Boolean

Overloads:

  • #enabledBoolean

    Returns whether ActivityNotification is enabled

    Returns:

    • (Boolean)

      Whether ActivityNotification is enabled.

  • #enabled=(value) ⇒ Boolean

    Sets whether ActivityNotification is enabled

    Parameters:

    • enabled (Boolean)

      The new enabled

    Returns:

    • (Boolean)

      Whether ActivityNotification is enabled.



17
18
19
# File 'lib/activity_notification/config.rb', line 17

def enabled
  @enabled
end

#mailerString #mailer=(value) ⇒ String

Overloads:

  • #mailerString

    Returns mailer class for email notification

    Returns:

    • (String)

      Mailer class for email notification.

  • #mailer=(value) ⇒ String

    Sets mailer class for email notification

    Parameters:

    • mailer (String)

      The new mailer

    Returns:

    • (String)

      Mailer class for email notification.



110
111
112
# File 'lib/activity_notification/config.rb', line 110

def mailer
  @mailer
end

#mailer_attachmentsHash, ... #mailer_attachments=(value) ⇒ Hash, ...

Overloads:

  • #mailer_attachmentsHash, ...

    Returns attachment specification(s) for notification emails

    Returns:

    • (Hash, Array<Hash>, Proc, nil)

      Attachment specification(s) for notification emails.

  • #mailer_attachments=(value) ⇒ Hash, ...

    Sets attachment specification(s) for notification emails

    Parameters:

    • mailer_attachments (Hash, Array<Hash>, Proc, nil)

      The new mailer_attachments

    Returns:

    • (Hash, Array<Hash>, Proc, nil)

      Attachment specification(s) for notification emails.



101
102
103
# File 'lib/activity_notification/config.rb', line 101

def mailer_attachments
  @mailer_attachments
end

#mailer_ccString, ... #mailer_cc=(value) ⇒ String, ...

Overloads:

  • #mailer_ccString, ...

    Returns carbon copy (CC) email address(es) for notification email

    Returns:

    • (String, Array<String>, Proc)

      CC email address(es) for notification email.

  • #mailer_cc=(value) ⇒ String, ...

    Sets carbon copy (CC) email address(es) for notification email

    Parameters:

    • mailer_cc (String, Array<String>, Proc)

      The new mailer_cc

    Returns:

    • (String, Array<String>, Proc)

      CC email address(es) for notification email.



92
93
94
# File 'lib/activity_notification/config.rb', line 92

def mailer_cc
  @mailer_cc
end

#mailer_senderString #mailer_sender=(value) ⇒ String

Overloads:

  • #mailer_senderString

    Returns email address as sender of notification email

    Returns:

    • (String)

      Email address as sender of notification email.

  • #mailer_sender=(value) ⇒ String

    Sets email address as sender of notification email

    Parameters:

    • mailer_sender (String)

      The new mailer_sender

    Returns:

    • (String)

      Email address as sender of notification email.



83
84
85
# File 'lib/activity_notification/config.rb', line 83

def mailer_sender
  @mailer_sender
end

#mailer_templates_dirString #mailer_templates_dir=(value) ⇒ String

Overloads:

  • #mailer_templates_dirString

    Returns custom mailer templates directory

    Returns:

    • (String)

      Custom mailer templates directory.

  • #mailer_templates_dir=(value) ⇒ String

    Sets custom mailer templates directory

    Parameters:

    • mailer_templates_dir (String)

      The new custom mailer templates directory

    Returns:

    • (String)

      Custom mailer templates directory.



155
156
157
# File 'lib/activity_notification/config.rb', line 155

def mailer_templates_dir
  @mailer_templates_dir
end

#notification_api_channel_prefixString #notification_api_channel_prefix=(value) ⇒ String

Overloads:

  • #notification_api_channel_prefixString

    Returns notification API channel prefix for ActionCable

    Returns:

    • (String)

      Notification API channel prefix for ActionCable.

  • #notification_api_channel_prefix=(value) ⇒ String

    Sets notification API channel prefix for ActionCable

    Parameters:

    • notification_api_channel_prefix (String)

      The new notification_api_channel_prefix

    Returns:

    • (String)

      Notification API channel prefix for ActionCable.



232
233
234
# File 'lib/activity_notification/config.rb', line 232

def notification_api_channel_prefix
  @notification_api_channel_prefix
end

#notification_channel_prefixString #notification_channel_prefix=(value) ⇒ String

Overloads:

  • #notification_channel_prefixString

    Returns notification channel prefix for ActionCable

    Returns:

    • (String)

      Notification channel prefix for ActionCable.

  • #notification_channel_prefix=(value) ⇒ String

    Sets notification channel prefix for ActionCable

    Parameters:

    • notification_channel_prefix (String)

      The new notification_channel_prefix

    Returns:

    • (String)

      Notification channel prefix for ActionCable.



223
224
225
# File 'lib/activity_notification/config.rb', line 223

def notification_channel_prefix
  @notification_channel_prefix
end

#notification_table_nameString #notification_table_name=(value) ⇒ String

Overloads:

  • #notification_table_nameString

    Returns table name to store notifications

    Returns:

    • (String)

      Table name to store notifications.

  • #notification_table_name=(value) ⇒ String

    Sets table name to store notifications

    Parameters:

    • notification_table_name (String)

      The new notification_table_name

    Returns:

    • (String)

      Table name to store notifications.



26
27
28
# File 'lib/activity_notification/config.rb', line 26

def notification_table_name
  @notification_table_name
end

#opened_index_limitInteger #opened_index_limit=(value) ⇒ Integer

Overloads:

  • #opened_index_limitInteger

    Returns default limit to query for opened notifications

    Returns:

    • (Integer)

      Default limit to query for opened notifications.

  • #opened_index_limit=(value) ⇒ Integer

    Sets default limit to query for opened notifications

    Parameters:

    • opened_index_limit (Integer)

      The new opened_index_limit

    Returns:

    • (Integer)

      Default limit to query for opened notifications.



164
165
166
# File 'lib/activity_notification/config.rb', line 164

def opened_index_limit
  @opened_index_limit
end

#Boolean

Returns ORM name for ActivityNotification (:active_record, :mongoid or :dynamodb)

Returns:

  • (Boolean)

    ORM name for ActivityNotification (:active_record, :mongoid or :dynamodb).



8
9
10
# File 'lib/activity_notification/config.rb', line 8

def orm
  @orm
end

#parent_channelString #parent_channel=(value) ⇒ String

Overloads:

  • #parent_channelString

    Returns base channel class for notification_channel

    Returns:

    • (String)

      Base channel class for notification_channel.

  • #parent_channel=(value) ⇒ String

    Sets base channel class for notification_channel

    Parameters:

    • parent_channel (String)

      The new parent_channel

    Returns:

    • (String)

      Base channel class for notification_channel.



146
147
148
# File 'lib/activity_notification/config.rb', line 146

def parent_channel
  @parent_channel
end

#parent_controllerString #parent_controller=(value) ⇒ String

Overloads:

  • #parent_controllerString

    Returns base controller class for notifications_controller

    Returns:

    • (String)

      Base controller class for notifications_controller.

  • #parent_controller=(value) ⇒ String

    Sets base controller class for notifications_controller

    Parameters:

    • parent_controller (String)

      The new parent_controller

    Returns:

    • (String)

      Base controller class for notifications_controller.



137
138
139
# File 'lib/activity_notification/config.rb', line 137

def parent_controller
  @parent_controller
end

#parent_jobString #parent_job=(value) ⇒ String

Overloads:

  • #parent_jobString

    Returns base job class for delayed notifications

    Returns:

    • (String)

      Base job class for delayed notifications.

  • #parent_job=(value) ⇒ String

    Sets base job class for delayed notifications

    Parameters:

    • parent_job (String)

      The new parent_job

    Returns:

    • (String)

      Base job class for delayed notifications.



128
129
130
# File 'lib/activity_notification/config.rb', line 128

def parent_job
  @parent_job
end

#parent_mailerString #parent_mailer=(value) ⇒ String

Overloads:

  • #parent_mailerString

    Returns base mailer class for email notification

    Returns:

    • (String)

      Base mailer class for email notification.

  • #parent_mailer=(value) ⇒ String

    Sets base mailer class for email notification

    Parameters:

    • parent_mailer (String)

      The new parent_mailer

    Returns:

    • (String)

      Base mailer class for email notification.



119
120
121
# File 'lib/activity_notification/config.rb', line 119

def parent_mailer
  @parent_mailer
end

#rescue_optional_target_errorsBoolean #rescue_optional_target_errors=(value) ⇒ Boolean

Overloads:

  • #rescue_optional_target_errorsBoolean

    Returns whether activity_notification internally rescues optional target errors

    Returns:

    • (Boolean)

      Whether activity_notification internally rescues optional target errors.

  • #rescue_optional_target_errors=(value) ⇒ Boolean

    Sets whether activity_notification internally rescues optional target errors

    Parameters:

    • rescue_optional_target_errors (Boolean)

      The new rescue_optional_target_errors

    Returns:

    • (Boolean)

      Whether activity_notification internally rescues optional target errors.



241
242
243
# File 'lib/activity_notification/config.rb', line 241

def rescue_optional_target_errors
  @rescue_optional_target_errors
end

#restrict_api_response_fieldsBoolean #restrict_api_response_fields=(value) ⇒ Boolean

Overloads:

  • #restrict_api_response_fieldsBoolean

    Returns whether the REST API restricts embedded associated records to their id and printable_* method values

    Returns:

    • (Boolean)

      Whether the REST API restricts embedded associated records to their id and printable_* method values.

  • #restrict_api_response_fields=(value) ⇒ Boolean

    Sets whether the REST API restricts embedded associated records (target, notifiable, notifier, group, group members and subscription target) in JSON responses to their id and printable_* method values instead of all database columns. This is an opt-in hardening option to avoid exposing columns the frontend does not need (e.g. authentication identifiers on an associated user record). It is disabled by default to preserve the existing response shape.

    Parameters:

    • restrict_api_response_fields (Boolean)

      The new restrict_api_response_fields

    Returns:

    • (Boolean)

      Whether the REST API restricts embedded associated records to their id and printable_* method values.



250
251
252
# File 'lib/activity_notification/config.rb', line 250

def restrict_api_response_fields
  @restrict_api_response_fields
end

#store_with_associated_recordsBoolean

Returns whether activity_notification stores notification records including associated records like target and notifiable

Returns:

  • (Boolean)

    Whether activity_notification stores Notification records including associated records like target and notifiable.



187
188
189
# File 'lib/activity_notification/config.rb', line 187

def store_with_associated_records
  @store_with_associated_records
end

#subscribe_as_defaultBoolean #default_subscription=(value) ⇒ Boolean

Overloads:

  • #subscribe_as_defaultBoolean

    Returns default subscription value to use when the subscription record does not configured

    Returns:

    • (Boolean)

      Default subscription value to use when the subscription record does not configured.

  • #default_subscription=(value) ⇒ Boolean

    Sets default subscription value to use when the subscription record does not configured

    Parameters:

    • subscribe_as_default (Boolean)

      The new subscribe_as_default

    Returns:

    • (Boolean)

      Default subscription value to use when the subscription record does not configured.



62
63
64
# File 'lib/activity_notification/config.rb', line 62

def subscribe_as_default
  @subscribe_as_default
end

#subscribe_to_email_as_defaultBoolean

Returns default email subscription value to use when the subscription record does not configured

Returns:

  • (Boolean)

    Default email subscription value to use when the subscription record does not configured.



305
306
307
308
309
# File 'lib/activity_notification/config.rb', line 305

def subscribe_to_email_as_default
  return false unless @subscribe_as_default

  @subscribe_to_email_as_default.nil? ? @subscribe_as_default : @subscribe_to_email_as_default
end

#subscribe_to_optional_targets_as_defaultBoolean

Returns default optional target subscription value to use when the subscription record does not configured

Returns:

  • (Boolean)

    Default optional target subscription value to use when the subscription record does not configured.



313
314
315
316
317
# File 'lib/activity_notification/config.rb', line 313

def subscribe_to_optional_targets_as_default
  return false unless @subscribe_as_default

  @subscribe_to_optional_targets_as_default.nil? ? @subscribe_as_default : @subscribe_to_optional_targets_as_default
end

#subscription_enabledBoolean #subscription_enabled=(value) ⇒ Boolean

Overloads:

  • #subscription_enabledBoolean

    Returns whether activity_notification manages subscriptions

    Returns:

    • (Boolean)

      Whether activity_notification manages subscriptions.

  • #subscription_enabled=(value) ⇒ Boolean

    Sets whether activity_notification manages subscriptions

    Parameters:

    • subscription_enabled (Boolean)

      The new subscription_enabled

    Returns:

    • (Boolean)

      Whether activity_notification manages subscriptions.



53
54
55
# File 'lib/activity_notification/config.rb', line 53

def subscription_enabled
  @subscription_enabled
end

#subscription_table_nameString #subscription_table_name=(value) ⇒ String

Overloads:

  • #subscription_table_nameString

    Returns table name to store subscriptions

    Returns:

    • (String)

      Table name to store subscriptions.

  • #subscription_table_name=(value) ⇒ String

    Sets table name to store subscriptions

    Parameters:

    • notification_table_name (String)

      The new subscription_table_name

    Returns:

    • (String)

      Table name to store subscriptions.



35
36
37
# File 'lib/activity_notification/config.rb', line 35

def subscription_table_name
  @subscription_table_name
end