Module: ActivityNotification::ActsAsNotifier

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

Overview

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

Class Method Summary collapse

Class Method Details

.acts_as_notifier(options = {}) ⇒ Hash

Adds required configurations to notifier models.

Parameters:

  • :printable_name or :printable_notifier_name

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

Examples:

Define printable name with user name of name field

# app/models/user.rb
class User < ActiveRecord::Base
  acts_as_notifier printable_name: :name
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_notifier.rb', line 23

def acts_as_notifier(options = {})
  include Notifier

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

.available_notifier_optionsArray<Symbol>

Returns array of available notifier options in acts_as_notifier.

Returns:

  • (Array<Symbol>)

    Array of available notifier options



32
33
34
# File 'lib/activity_notification/roles/acts_as_notifier.rb', line 32

def available_notifier_options
  [:printable_notifier_name, :printable_name].freeze
end