Sha256: 7bc3253a7cb412e34fd222bde572fc73e3166c74db4ca9555a37c57ebcd716a2
Contents?: true
Size: 644 Bytes
Versions: 3
Compression:
Stored size: 644 Bytes
Contents
require 'browser' module Sojourn class Browser < ActiveRecord::Base has_many :requests, foreign_key: :sojourn_browser_id has_many :events, through: :requests def self.from_request(request) where(user_agent: request.user_agent).first_or_initialize end before_validation do self.name ||= browser.name self.version ||= browser.version self.platform ||= browser.platform self.known ||= browser.known? self.bot ||= browser.bot? true # otherwise .valid? will return false end private def browser @browser ||= ::Browser.new(user_agent: user_agent) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sojourn-1.0.0.pre2 | lib/sojourn/browser.rb |
sojourn-1.0.0.pre | lib/sojourn/browser.rb |
sojourn-0.0.7 | lib/sojourn/browser.rb |