Module: Authlogic::ActsAsAuthentic::Email::Config
- Defined in:
- lib/authlogic/acts_as_authentic/email.rb
Overview
Configuration to modify how Authlogic handles the email field.
Instance Method Summary collapse
-
#email_field(value = nil) ⇒ Object
(also: #email_field=)
The name of the field that stores email addresses.
-
#merge_validates_format_of_email_field_options(options = {}) ⇒ Object
See merge_validates_length_of_email_field_options.
-
#merge_validates_length_of_email_field_options(options = {}) ⇒ Object
A convenience function to merge options into the validates_length_of_email_field_options.
-
#merge_validates_uniqueness_of_email_field_options(options = {}) ⇒ Object
See merge_validates_length_of_email_field_options.
-
#validate_email_field(value = nil) ⇒ Object
(also: #validate_email_field=)
Toggles validating the email field or not.
-
#validates_format_of_email_field_options(value = nil) ⇒ Object
(also: #validates_format_of_email_field_options=)
A hash of options for the validates_format_of call for the email field.
-
#validates_length_of_email_field_options(value = nil) ⇒ Object
(also: #validates_length_of_email_field_options=)
A hash of options for the validates_length_of call for the email field.
-
#validates_uniqueness_of_email_field_options(value = nil) ⇒ Object
(also: #validates_uniqueness_of_email_field_options=)
A hash of options for the validates_uniqueness_of call for the email field.
Instance Method Details
#email_field(value = nil) ⇒ Object Also known as: email_field=
The name of the field that stores email addresses.
-
Default:
:email, if it exists -
Accepts:
Symbol
22 23 24 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 22 def email_field(value = nil) rw_config(:email_field, value, first_column_to_exist(nil, :email, :email_address)) end |
#merge_validates_format_of_email_field_options(options = {}) ⇒ Object
See merge_validates_length_of_email_field_options. The same thing except for validates_format_of_email_field_options.
122 123 124 125 126 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 122 def ( = {}) deprecate_authlogic_config("merge_validates_format_of_email_field_options") self. = .merge() end |
#merge_validates_length_of_email_field_options(options = {}) ⇒ Object
A convenience function to merge options into the validates_length_of_email_field_options. So instead of:
self. =
.merge(:my_option => my_value)
You can do this:
:my_option => my_value
65 66 67 68 69 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 65 def ( = {}) deprecate_authlogic_config("merge_validates_length_of_email_field_options") self. = .merge() end |
#merge_validates_uniqueness_of_email_field_options(options = {}) ⇒ Object
See merge_validates_length_of_email_field_options. The same thing except for validates_uniqueness_of_email_field_options.
163 164 165 166 167 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 163 def ( = {}) deprecate_authlogic_config("merge_validates_uniqueness_of_email_field_options") self. = .merge() end |
#validate_email_field(value = nil) ⇒ Object Also known as: validate_email_field=
Toggles validating the email field or not.
-
Default:
true -
Accepts:
Boolean
31 32 33 34 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 31 def validate_email_field(value = nil) deprecate_authlogic_config("validate_email_field") rw_config(:validate_email_field, value, true) end |
#validates_format_of_email_field_options(value = nil) ⇒ Object Also known as: validates_format_of_email_field_options=
A hash of options for the validates_format_of call for the email field. Allows you to change this however you want.
Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_format_of_email_field_options to merge options.
To validate international email addresses, enable the provided alternate regex:
“‘ validates_format_of_email_field_options(
with: Authlogic::Regex.email_nonascii
) “‘
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 101 def (value = nil) deprecate_authlogic_config("validates_format_of_email_field_options") rw_config( :validates_format_of_email_field_options, value, with: Authlogic::Regex::EMAIL, message: proc do I18n.t( "error_messages.email_invalid", default: "should look like an email address." ) end ) end |
#validates_length_of_email_field_options(value = nil) ⇒ Object Also known as: validates_length_of_email_field_options=
A hash of options for the validates_length_of call for the email field. Allows you to change this however you want.
Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_length_of_email_field_options to merge options.
-
Default:
=> 100 -
Accepts:
Hash of options accepted by validates_length_of
47 48 49 50 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 47 def (value = nil) deprecate_authlogic_config("validates_length_of_email_field_options") rw_config(:validates_length_of_email_field_options, value, maximum: 100) end |
#validates_uniqueness_of_email_field_options(value = nil) ⇒ Object Also known as: validates_uniqueness_of_email_field_options=
A hash of options for the validates_uniqueness_of call for the email field. Allows you to change this however you want.
Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or merge options into it. Checkout the convenience function merge_validates_uniqueness_of_email_field_options to merge options.
-
Default:
{ :case_sensitive => false, :scope => validations_scope, :if => "#{email_field}_changed?".to_sym }
-
Accepts:
Hash of options accepted by validates_uniqueness_of
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/authlogic/acts_as_authentic/email.rb', line 146 def (value = nil) deprecate_authlogic_config("validates_uniqueness_of_email_field_options") rw_config( :validates_uniqueness_of_email_field_options, value, case_sensitive: false, scope: validations_scope, if: "#{email_field}_changed?".to_sym ) end |