Class: Registration
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Registration
- Defined in:
- app/models/registration.rb
Constant Summary collapse
- PENDING =
Constants
"pending"- VERIFIED =
"verified"- STATUS =
{ PENDING => "Pending", VERIFIED => "Verified" }
- STATUS_REVERSE =
{ "Pending" => PENDING, "Verified" => VERIFIED }
Instance Method Summary collapse
- #can_be_deleted? ⇒ Boolean
-
#can_be_edited? ⇒ Boolean
Permission Methods ——————.
-
#display_name ⇒ Object
-
Return mobile number with dialling prefix == Examples >>> registration.display_name => “+919880123456”.
-
-
#pending! ⇒ Object
change the status to :verified Return the status == Examples >>> registration.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 >>> registration.verify! => “verified”.
Instance Method Details
#can_be_deleted? ⇒ Boolean
93 94 95 |
# File 'app/models/registration.rb', line 93 def can_be_deleted? pending? end |
#can_be_edited? ⇒ Boolean
Permission Methods
89 90 91 |
# File 'app/models/registration.rb', line 89 def can_be_edited? pending? end |
#display_name ⇒ Object
-
Return mobile number with dialling prefix
Examples
>>> registration.display_name
=> "+919880123456"
104 105 106 |
# File 'app/models/registration.rb', line 104 def display_name "#{self.dialing_prefix} #{self.mobile_number}" end |
#pending! ⇒ Object
change the status to :verified Return the status
Examples
>>> registration.pending!
=> "pending"
73 74 75 |
# File 'app/models/registration.rb', line 73 def pending! self.update_attribute(:status, PENDING) end |
#pending? ⇒ Boolean
-
Return true if the user is pending, else false.
Examples
>>> registration.pending?
=> true
56 57 58 |
# File 'app/models/registration.rb', line 56 def pending? (status == PENDING) end |
#verified? ⇒ Boolean
-
Return true if the user is not verified, else false.
Examples
>>> registration.verified?
=> true
64 65 66 |
# File 'app/models/registration.rb', line 64 def verified? (status == VERIFIED) end |
#verify! ⇒ Object
change the status to :verified Return the status
Examples
>>> registration.verify!
=> "verified"
82 83 84 |
# File 'app/models/registration.rb', line 82 def verify! self.update_attribute(:status, VERIFIED) end |