Module: Authpwn::UserExtensions::EmailField
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/authpwn_rails/user_extensions/email_field.rb
Overview
Augments the User model with an email virtual attribute.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#email ⇒ Object
The e-mail from the user’s Email credential.
-
#email=(new_email) ⇒ Object
Sets the e-mail on the user’s Email credential.
-
#email_credential ⇒ Object
Credentials::Email instance associated with this user.
Instance Method Details
#email ⇒ Object
The e-mail from the user’s Email credential.
Returns nil if this user has no Email credential.
46 47 48 49 |
# File 'lib/authpwn_rails/user_extensions/email_field.rb', line 46 def email credential = self.email_credential credential && credential.email end |
#email=(new_email) ⇒ Object
Sets the e-mail on the user’s Email credential.
Creates a new Credentials::Email instance if necessary.
54 55 56 57 58 59 60 61 |
# File 'lib/authpwn_rails/user_extensions/email_field.rb', line 54 def email=(new_email) if credential = self.email_credential credential.email = new_email else credentials << Credentials::Email.new(email: new_email) end new_email end |
#email_credential ⇒ Object
Credentials::Email instance associated with this user.
39 40 41 |
# File 'lib/authpwn_rails/user_extensions/email_field.rb', line 39 def email_credential credentials.find { |c| c.instance_of?(Credentials::Email) } end |