Class: IfdTools::Tracking::Event

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ifd_tools/tracking/event.rb

Direct Known Subclasses

ApplicationEvent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.event_typesObject



27
28
29
30
31
# File 'app/models/ifd_tools/tracking/event.rb', line 27

def event_types
  Dir["#{Rails.root}/app/models/ifd_tools/tracking/*.rb"].each { |f| require f }
  Dir[File.expand_path(File.join(File.dirname(__FILE__), "/*.rb"))].delete_if { |f| f.end_with? "/event.rb" }.each { |f| require f }
  subclasses
end

.platform_for_request(request) ⇒ Object



33
34
35
36
37
38
39
# File 'app/models/ifd_tools/tracking/event.rb', line 33

def platform_for_request(request)
  if request.headers["HTTP_USER_AGENT"] =~ /Macintosh|iPad|iPhone/
    "mac"
  else
    "pc"
  end
end

.top_contentObject



41
42
43
44
45
46
# File 'app/models/ifd_tools/tracking/event.rb', line 41

def top_content
  content = self.where("type != ?", "IfdTools::Tracking::ApplicationEvent").group(:trackable_id).order("count(trackable_id) desc").limit(25).collect do |e|
    e.trackable_type.constantize.find(e.trackable_id) rescue nil
  end
  content.compact.sort { |a,b| b.trackable_activity <=> a.trackable_activity }
end

Instance Method Details

#assign_trackable_item_by_id(id) ⇒ Object



15
16
17
18
# File 'app/models/ifd_tools/tracking/event.rb', line 15

def assign_trackable_item_by_id(id)
  # self.trackable = AssociatedClass.find(id)
  raise "Must implement 'assign_trackable_item_by_id' in each IfdTools::Tracking::Event subclass to set association"
end