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



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

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

.platform_for_request(request) ⇒ Object



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

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

.top_contentObject



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

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



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

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