summaryrefslogtreecommitdiffstats
path: root/app/models/concerns/browser_detection.rb
blob: d42d0a5c998283946908bcaf5c47730689533853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module BrowserDetection
  extend ActiveSupport::Concern

  included do
    before_save :assign_user_agent
  end

  def detection
    @detection ||= Browser.new(user_agent)
  end

  def browser
    detection.id
  end

  def platform
    detection.platform.id
  end

  private

  def assign_user_agent
    self.user_agent ||= ''
  end
end