Module: IfdTools::Analytics::Trackable

Defined in:
lib/ifd_tools/analytics/trackable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/ifd_tools/analytics/trackable.rb', line 5

def self.included(base)
  base.class_eval do
    has_many :tracking_events, :class_name => 'IfdTools::Tracking::Event', foreign_key: :trackable_id, dependent: :destroy
  end
end

Instance Method Details

#trackable_activityObject



24
25
26
# File 'lib/ifd_tools/analytics/trackable.rb', line 24

def trackable_activity
  tracking_events.count
end

#trackable_resourceObject

Override if you might want to link to something else



20
21
22
# File 'lib/ifd_tools/analytics/trackable.rb', line 20

def trackable_resource
  self
end

#trackable_titleObject



11
12
13
# File 'lib/ifd_tools/analytics/trackable.rb', line 11

def trackable_title
  name rescue title
end

#trackable_typeObject



15
16
17
# File 'lib/ifd_tools/analytics/trackable.rb', line 15

def trackable_type
  self.class.name.titleize
end