Module: PublicActivity::Common::ClassMethods

Defined in:
lib/public_activity/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 Tracked::ClassMethods#tracked. Returns nil when no hook exists for given action Common#get_hook

Parameters:

  • key (String, Symbol)

    action to retrieve a hook for

Returns:

  • (Proc, nil)

    callable hook or nil

See Also:

  • Tracked#get_hook

Since:

  • 0.4.0


86
87
88
89
90
91
92
93
# File 'lib/public_activity/common.rb', line 86

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

#set_public_activity_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


68
69
70
71
72
73
74
# File 'lib/public_activity/common.rb', line 68

def set_public_activity_class_defaults
  self.activity_owner_global             = nil
  self.activity_recipient_global         = nil
  self.activity_parameters_global        = {}
  self.activity_hooks                    = {}
  self.activity_custom_fields_global     = {}
end