Class: Maia::Device

Inherits:
ApplicationRecord show all
Defined in:
app/models/maia/device.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.androidObject



34
35
36
# File 'app/models/maia/device.rb', line 34

def self.android
  where platform: 'android'
end

.iosObject



30
31
32
# File 'app/models/maia/device.rb', line 30

def self.ios
  where platform: 'ios'
end

.owned_by(pushable) ⇒ Object



22
23
24
# File 'app/models/maia/device.rb', line 22

def self.owned_by(pushable)
  where(pushable: pushable).distinct
end

.tokensObject



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

def self.tokens
  pluck(:token)
end

.unknownObject



38
39
40
# File 'app/models/maia/device.rb', line 38

def self.unknown
  where platform: nil
end

Instance Method Details

#expire_token_inObject



14
15
16
# File 'app/models/maia/device.rb', line 14

def expire_token_in
  14.days
end

#reset_token_expiryObject



10
11
12
# File 'app/models/maia/device.rb', line 10

def reset_token_expiry
  self.token_expires_at = Time.current + expire_token_in
end

#token_expired?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/maia/device.rb', line 18

def token_expired?
  token_expires_at.nil? || token_expires_at.past?
end