Class: Registration
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Registration
- Defined in:
- app/models/registration.rb
Constant Summary collapse
- EXCLUDED_JSON_ATTRIBUTES =
Constants
[:status, :created_at, :updated_at]
- PENDING =
"pending"- VERIFIED =
"verified"- STATUS =
{ PENDING => "Pending", VERIFIED => "Verified" }
- STATUS_REVERSE =
{ "Pending" => PENDING, "Verified" => VERIFIED }
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Object
Exclude some attributes info from json output.
- #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
#as_json(options = {}) ⇒ Object
Exclude some attributes info from json output.
52 53 54 55 56 57 58 |
# File 'app/models/registration.rb', line 52 def as_json(={}) [:except] ||= EXCLUDED_JSON_ATTRIBUTES #options[:include] ||= [] #options[:methods] = [] #options[:methods] << :profile_image super() end |
#can_be_deleted? ⇒ Boolean
104 105 106 |
# File 'app/models/registration.rb', line 104 def can_be_deleted? pending? end |
#can_be_edited? ⇒ Boolean
Permission Methods
100 101 102 |
# File 'app/models/registration.rb', line 100 def can_be_edited? pending? end |
#display_name ⇒ Object
-
Return mobile number with dialling prefix
Examples
>>> registration.display_name
=> "+919880123456"
115 116 117 |
# File 'app/models/registration.rb', line 115 def display_name "#{self.dialing_prefix} #{self.mobile_number}" end |
#pending! ⇒ Object
change the status to :verified Return the status
Examples
>>> registration.pending!
=> "pending"
84 85 86 |
# File 'app/models/registration.rb', line 84 def pending! self.update_attribute(:status, PENDING) end |
#pending? ⇒ Boolean
-
Return true if the user is pending, else false.
Examples
>>> registration.pending?
=> true
67 68 69 |
# File 'app/models/registration.rb', line 67 def pending? (status == PENDING) end |
#verified? ⇒ Boolean
-
Return true if the user is not verified, else false.
Examples
>>> registration.verified?
=> true
75 76 77 |
# File 'app/models/registration.rb', line 75 def verified? (status == VERIFIED) end |
#verify! ⇒ Object
change the status to :verified Return the status
Examples
>>> registration.verify!
=> "verified"
93 94 95 |
# File 'app/models/registration.rb', line 93 def verify! self.update_attribute(:status, VERIFIED) end |