Module: Devise::Latch

Defined in:
lib/devise_latcheable/adapter.rb

Class Method Summary collapse

Class Method Details

.configObject



30
31
32
# File 'lib/devise_latcheable/adapter.rb', line 30

def self.config
  @yaml_config
end

.pair(code) ⇒ Object

> Pairs an user with the server.

@returns Account ID on success and nil on failure


8
9
10
11
12
# File 'lib/devise_latcheable/adapter.rb', line 8

def self.pair(code)
  res = @latch_instance.pair code
  return nil if res.data.nil?
  res.data['accountId']
end

.unlocked?(account_id) ⇒ Boolean

> Checks if the app lock is open

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'lib/devise_latcheable/adapter.rb', line 15

def self.unlocked?()
  res = @latch_instance.status 
  return false unless res.error.nil?
  
  key = res.data['operations'].keys.first
  status = res.data['operations'][key]['status']
  status == 'on'
end

.unpair(account_id) ⇒ Object

> Removes the pairing from lath



25
26
27
28
# File 'lib/devise_latcheable/adapter.rb', line 25

def self.unpair()
  res = @latch_instance.unpair 
  res.error.nil? ? true : false
end