Sha256: 920eb8024a8b9e6e1d877c0a3d7aa8a273847bece3428357c380d966b2a75cc8

Contents?: true

Size: 931 Bytes

Versions: 8

Compression:

Stored size: 931 Bytes

Contents

module Landable
  module Traffic
    class UserAgent < ActiveRecord::Base
      include Landable::Traffic::TableName
      self.record_timestamps = false

      lookup_by  :user_agent, cache: 50, find_or_create: true

      lookup_for :user_agent_type, class_name: UserAgentType
      lookup_for :device,          class_name: Device
      lookup_for :platform,        class_name: Platform
      lookup_for :browser,         class_name: Traffic::Browser

      has_many :visitors

      before_save do
        self.user_agent_type ||= case user_agent
                                 when /pingdom|newrelicpinger/i
                                   'ping'
                                 when /scanalert|tinfoilsecurity/i
                                   'scan'
                                 when /bot|crawl|spider/i
                                   'crawl'
                                 end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
landable-1.9.2 app/models/landable/traffic/user_agent.rb
landable-1.9.1 app/models/landable/traffic/user_agent.rb
landable-1.9.0 app/models/landable/traffic/user_agent.rb
landable-1.9.0.rc2 app/models/landable/traffic/user_agent.rb
landable-1.9.0.rc1 app/models/landable/traffic/user_agent.rb
landable-1.8.0 app/models/landable/traffic/user_agent.rb
landable-1.7.1.rc1 app/models/landable/traffic/user_agent.rb
landable-1.7.0 app/models/landable/traffic/user_agent.rb