Class: Masks::Device

Inherits:
ApplicationModel show all
Defined in:
app/models/masks/device.rb

Overview

Represents a device, used for interacting with a session.

Device detection is optionally added with the Device credential, using the device-detector gem.

Instance Method Summary collapse

Instance Method Details

#detectorObject



26
27
28
# File 'app/models/masks/device.rb', line 26

def detector
  @detector ||= DeviceDetector.new(session.user_agent)
end

#fingerprintObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/masks/device.rb', line 13

def fingerprint
  return unless detector.known?

  input = [
    detector.name,
    detector.os_name,
    detector.device_name,
    detector.device_type
  ].compact.join("-")

  Digest::SHA512.hexdigest(input)
end