Class: Pushable::Device
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pushable::Device
- Defined in:
- app/models/pushable/device.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.android ⇒ Object
22 23 24 |
# File 'app/models/pushable/device.rb', line 22 def self.android where(platform: 'android') end |
.ios ⇒ Object
26 27 28 |
# File 'app/models/pushable/device.rb', line 26 def self.ios where(platform: 'ios') end |
.owned_by(pushable) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/models/pushable/device.rb', line 30 def self.owned_by(pushable) klass = pushable.klass.name table = pushable.table.name joins("JOIN #{table} ON #{table}.id = pushable_devices.pushable_id"). where(pushable_type: klass). merge(pushable). uniq end |
Instance Method Details
#expire_token_in ⇒ Object
14 15 16 |
# File 'app/models/pushable/device.rb', line 14 def expire_token_in 14.days end |
#reset_token_expiry ⇒ Object
10 11 12 |
# File 'app/models/pushable/device.rb', line 10 def reset_token_expiry self.token_expires_at = Time.current + expire_token_in end |
#token_expired? ⇒ Boolean
18 19 20 |
# File 'app/models/pushable/device.rb', line 18 def token_expired? token_expires_at.nil? || token_expires_at.past? end |