Class: Ruze::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/ruze/device.rb

Overview

Holds the Gigya trusted-device identity (gmid/ucid) that lets us skip the two-factor prompt on subsequent logins.

This default implementation keeps the pair in memory only. For headless operation across process restarts, seed it from durable storage and persist the pair (see #gmid/#ucid) after a successful bootstrap:

device = Ruze::Device.new(gmid: stored_gmid, ucid: stored_ucid)
Ruze::Car.new(email, password, device: device)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gmid: nil, ucid: nil) ⇒ Device

Returns a new instance of Device.



12
13
14
15
# File 'lib/ruze/device.rb', line 12

def initialize(gmid: nil, ucid: nil)
  @gmid = gmid
  @ucid = ucid
end

Instance Attribute Details

#gmidObject (readonly)

Returns the value of attribute gmid.



16
17
18
# File 'lib/ruze/device.rb', line 16

def gmid
  @gmid
end

#ucidObject (readonly)

Returns the value of attribute ucid.



16
17
18
# File 'lib/ruze/device.rb', line 16

def ucid
  @ucid
end

Instance Method Details

#loadObject

Returns { gmid:, ucid: } or nil when no (complete) device is available.



19
20
21
22
23
# File 'lib/ruze/device.rb', line 19

def load
  return nil if gmid.to_s.empty? || ucid.to_s.empty?

  { gmid: gmid, ucid: ucid }
end

#save(gmid:, ucid:) ⇒ Object



25
26
27
28
# File 'lib/ruze/device.rb', line 25

def save(gmid:, ucid:)
  @gmid = gmid
  @ucid = ucid
end