Module: ActivityNotification::ActsAsGroup

Extended by:
ActiveSupport::Concern
Included in:
Models
Defined in:
lib/activity_notification/roles/acts_as_group.rb

Overview

Manages to add all required configurations to group models of notification.

Class Method Summary collapse

Class Method Details

.acts_as_group(options = {}) ⇒ Hash Also known as: acts_as_notification_group

Adds required configurations to group models.

Parameters:

  • :printable_name or :printable_notification_group_name

    • Printable notification group name. This parameter is a optional since ‘ActivityNotification::Common.printable_name` is used as default value. :printable_name is the same option as :printable_notification_group_name

Examples:

Define printable name with article title

# app/models/article.rb
class Article < ActiveRecord::Base
  acts_as_notification_group printable_name: ->(article) { "article \"#{article.title}\"" }
end

Parameters:

  • options (Hash) (defaults to: {})

    Options for notifier model configuration

Options Hash (options):

  • :printable_name (Symbol, Proc, String) — default: ActivityNotification::Common.printable_name

    Printable notifier target name

Returns:

  • (Hash)

    Configured parameters as notifier model



23
24
25
26
27
28
# File 'lib/activity_notification/roles/acts_as_group.rb', line 23

def acts_as_group(options = {})
  include Group

  options[:printable_notification_group_name] ||= options.delete(:printable_name)
  set_acts_as_parameters([:printable_notification_group_name], options)
end

.available_group_optionsArray<Symbol>

Returns array of available notification group options in acts_as_group.

Returns:

  • (Array<Symbol>)

    Array of available notification group options



33
34
35
# File 'lib/activity_notification/roles/acts_as_group.rb', line 33

def available_group_options
  [:printable_notification_group_name, :printable_name].freeze
end