Class: Device
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Device
- Defined in:
- app/models/device.rb
Constant Summary collapse
- PENDING =
Constants
"pending"
- VERIFIED =
"verified"
- BLOCKED =
"blocked"
- STATUS =
{ PENDING => "Pending", VERIFIED => "Verified", BLOCKED => "Blocked" }
- STATUS_REVERSE =
{ "Pending" => PENDING, "Verified" => VERIFIED, "Blocked" => BLOCKED }
Instance Method Summary collapse
-
#block! ⇒ Object
change the status to :blocked Return the status == Examples >>> device.block! => “blocked”.
-
#blocked? ⇒ Boolean
-
Return true if the user is not blocked, else false.
-
- #can_be_deleted? ⇒ Boolean
-
#can_be_edited? ⇒ Boolean
Permission Methods ——————.
-
#display_name ⇒ Object
-
Return full name == Examples >>> device.display_mobile_number => “+919880123456”.
-
-
#generate_otp ⇒ Object
Authentication Methods ———————-.
-
#pending! ⇒ Object
change the status to :pending Return the status == Examples >>> device.pending! => “pending”.
-
#pending? ⇒ Boolean
-
Return true if the user is pending, else false.
-
-
#verified? ⇒ Boolean
-
Return true if the user is not verified, else false.
-
-
#verify! ⇒ Object
change the status to :verified Return the status == Examples >>> device.verify! => “verified”.
Instance Method Details
#block! ⇒ Object
change the status to :blocked Return the status
Examples
>>> device.block!
=> "blocked"
116 117 118 |
# File 'app/models/device.rb', line 116 def block! self.update_attribute(:status, BLOCKED) end |
#blocked? ⇒ Boolean
-
Return true if the user is not blocked, else false.
Examples
>>> device.blocked?
=> true
89 90 91 |
# File 'app/models/device.rb', line 89 def blocked? (status == BLOCKED) end |
#can_be_deleted? ⇒ Boolean
127 128 129 |
# File 'app/models/device.rb', line 127 def can_be_deleted? false end |
#can_be_edited? ⇒ Boolean
Permission Methods
123 124 125 |
# File 'app/models/device.rb', line 123 def can_be_edited? false end |
#display_name ⇒ Object
-
Return full name
Examples
>>> device.display_mobile_number
=> "+919880123456"
145 146 147 |
# File 'app/models/device.rb', line 145 def display_name "#{self.device_name} - #{self.uuid}" end |
#generate_otp ⇒ Object
Authentication Methods
134 135 136 |
# File 'app/models/device.rb', line 134 def generate_otp self.otp = rand(10000..99999) end |
#pending! ⇒ Object
change the status to :pending Return the status
Examples
>>> device.pending!
=> "pending"
98 99 100 |
# File 'app/models/device.rb', line 98 def pending! self.update_attribute(:status, PENDING) end |
#pending? ⇒ Boolean
-
Return true if the user is pending, else false.
Examples
>>> device.pending?
=> true
73 74 75 |
# File 'app/models/device.rb', line 73 def pending? (status == PENDING) end |
#verified? ⇒ Boolean
-
Return true if the user is not verified, else false.
Examples
>>> device.verified?
=> true
81 82 83 |
# File 'app/models/device.rb', line 81 def verified? (status == VERIFIED) end |
#verify! ⇒ Object
change the status to :verified Return the status
Examples
>>> device.verify!
=> "verified"
107 108 109 |
# File 'app/models/device.rb', line 107 def verify! self.update_attribute(:status, VERIFIED) end |