mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 11:08:07 +01:00
28 lines
368 B
Ruby
28 lines
368 B
Ruby
|
# 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
|