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.



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/activity_notification/config.rb', line 228

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                                   = '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
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.



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

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.



178
179
180
# File 'lib/activity_notification/config.rb', line 178

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.



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

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.



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

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.



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

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.



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

def mailer
  @mailer
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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

def rescue_optional_target_errors
  @rescue_optional_target_errors
end

#store_with_associated_recordsBoolean

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

Returns:

  • (Boolean)

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



169
170
171
# File 'lib/activity_notification/config.rb', line 169

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.



275
276
277
278
279
# File 'lib/activity_notification/config.rb', line 275

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 optinal target subscription value to use when the subscription record does not configured.



283
284
285
286
287
# File 'lib/activity_notification/config.rb', line 283

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