Class: Devise::Customizers::UserName::AuthenticationKeys
- Inherits:
-
Object
- Object
- Devise::Customizers::UserName::AuthenticationKeys
- Extended by:
- Rails3::Assist::UseMacro
- Includes:
- Cream::GeneratorHelper, Rails3::Assist::BasicLogger
- Defined in:
- lib/generators/devise/customize/helpers/username_helper.rb
Instance Attribute Summary collapse
-
#login_attribute ⇒ Object
Returns the value of attribute login_attribute.
Instance Method Summary collapse
- #default_keys_stmt ⇒ Object
- #devise_init_content?(content) ⇒ Boolean
-
#initialize(user_class, login_attribute) ⇒ AuthenticationKeys
constructor
A new instance of AuthenticationKeys.
- #keys_stmt_replacement(name) ⇒ Object
- #modify_initializer ⇒ Object
Methods included from Cream::GeneratorHelper
Constructor Details
#initialize(user_class, login_attribute) ⇒ AuthenticationKeys
Returns a new instance of AuthenticationKeys.
123 124 125 126 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 123 def initialize user_class, login_attribute @user_class = user_class @login_attribute = login_attribute end |
Instance Attribute Details
#login_attribute ⇒ Object
Returns the value of attribute login_attribute.
121 122 123 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 121 def login_attribute @login_attribute end |
Instance Method Details
#default_keys_stmt ⇒ Object
143 144 145 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 143 def default_keys_stmt /# config.authentication_keys = [\s*:email\s*]/ end |
#devise_init_content?(content) ⇒ Boolean
135 136 137 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 135 def devise_init_content? content read_initializer(:devise) =~ content.to_regexp end |
#keys_stmt_replacement(name) ⇒ Object
139 140 141 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 139 def keys_stmt_replacement name "config.authentication_keys = [ :#{name} ]" end |
#modify_initializer ⇒ Object
128 129 130 131 132 133 |
# File 'lib/generators/devise/customize/helpers/username_helper.rb', line 128 def modify_initializer logger.debug 'modify devise initializer' return if devise_init_content? keys_stmt_replacement(login_attribute) replace_initializer_content :devise, :where => default_keys_stmt, :with => keys_stmt_replacement(login_attribute) end |