Module: UserNotification::Common::ClassMethods

Defined in:
lib/user_notification/common.rb

Overview

Provides some global methods for every model class.

Instance Method Summary collapse

Instance Method Details

#get_hook(key) ⇒ Proc?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extracts a hook from the :on option provided in Notifiable::ClassMethods#notifiable. Returns nil when no hook exists for given action UserNotification::Common#get_hook

Parameters:

  • key (String, Symbol)

    action to retrieve a hook for

Returns:

  • (Proc, nil)

    callable hook or nil

See Also:

  • Notifiable#get_hook

Since:

  • 0.4.0



146
147
148
149
150
151
152
153
# File 'lib/user_notification/common.rb', line 146

def get_hook(key)
  key = key.to_sym
  if self.notification_hooks.has_key?(key) and self.notification_hooks[key].is_a? Proc
    self.notification_hooks[key]
  else
    nil
  end
end

#set_user_notification_class_defaultsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



128
129
130
131
132
133
134
# File 'lib/user_notification/common.rb', line 128

def set_user_notification_class_defaults
  self.notification_owner_global             = nil
  self.notification_recipient_global         = nil
  self.notification_params_global            = {}
  self.notification_hooks                    = {}
  self.notification_custom_fields_global     = {}
end