Class: UserDevice
- Inherits:
-
Object
- Object
- UserDevice
- Includes:
- Mongoid::Document, Mongoid::Timestamps, Searchable
- Defined in:
- lib/models/user_device.rb
Overview
Device associated with a user’s install of the app store. Held within the user object itself as an embedded document
Direct Known Subclasses
Cat::CustomerDevice, Cl::CustomerDevice, Gehc::CustomerDevice
Constant Summary collapse
- ENROLLING =
Constants
'enrolling'
- REGISTERING =
'registering'
- AUTHORIZING =
'authorizing'
- UNREGISTERED =
'unregistered'
- PENDING =
'pending'
- REJECTED =
'rejected'
- APPROVED =
'approved'
- REMOVED =
'removed'
- DEREGISTERED =
'deregistered'
- KEEP_STATES =
[UNREGISTERED, PENDING, REJECTED, APPROVED].freeze
Class Method Summary collapse
-
.find_device_by(device_id) ⇒ Object
Find a user device by safely trying a number of approaches 1.
Instance Method Summary collapse
-
#approved? ⇒ Boolean
Is the device approved?.
-
#search_fields ⇒ Object
Define which fields to include in search text.
Methods included from Searchable
Class Method Details
.find_device_by(device_id) ⇒ Object
Find a user device by safely trying a number of approaches
-
By ID
-
By unique identifier
-
By app47 identifier
-
By token
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/models/user_device.rb', line 73 def self.find_device_by(device_id) raise 'Invalid ID' if device_id.blank? UserDevice.where(_id: device_id).first || UserDevice.where(unique_identifier: device_id).first || UserDevice.where(app47_identifier: device_id).first || UserDevice.where(token: device_id).first rescue StandardError nil end |
Instance Method Details
#approved? ⇒ Boolean
Is the device approved?
62 63 64 |
# File 'lib/models/user_device.rb', line 62 def approved? UserDevice::APPROVED.eql? state end |
#search_fields ⇒ Object
Define which fields to include in search text
55 56 57 |
# File 'lib/models/user_device.rb', line 55 def search_fields %w[state platform model manufacture os_version description] end |