Class: Sorcery::Model::Config
- Inherits:
-
Object
- Object
- Sorcery::Model::Config
- Defined in:
- lib/sorcery/model.rb
Overview
Each class which calls ‘activate_sorcery!’ receives an instance of this class. Every submodule which gets loaded may add accessors to this class so that all options will be configured from a single place.
Instance Attribute Summary collapse
-
#after_config ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#before_authenticate ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#crypted_password_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#custom_encryption_provider ⇒ Object
change default encryption_provider.
-
#email_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#encryption_algorithm ⇒ Object
change default encryption_provider.
-
#encryption_key ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#encryption_provider ⇒ Object
readonly
change default encryption_provider.
-
#password_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#salt_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#salt_join_token ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#stretches ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#subclasses_inherit_config ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#submodules ⇒ Object
change default username attribute, for example, to use :email as the login.
-
#username_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#reset! ⇒ Object
Resets all configuration options to their default values.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/sorcery/model.rb', line 164 def initialize @defaults = { :@submodules => [], :@username_attribute_name => :username, :@password_attribute_name => :password, :@email_attribute_name => :email, :@crypted_password_attribute_name => :crypted_password, :@encryption_algorithm => :bcrypt, :@encryption_provider => CryptoProviders::BCrypt, :@custom_encryption_provider => nil, :@encryption_key => nil, :@salt_join_token => "", :@salt_attribute_name => :salt, :@stretches => nil, :@subclasses_inherit_config => false, :@before_authenticate => [], :@after_config => [] } reset! end |
Instance Attribute Details
#after_config ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def after_config @after_config end |
#before_authenticate ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def before_authenticate @before_authenticate end |
#crypted_password_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def crypted_password_attribute_name @crypted_password_attribute_name end |
#custom_encryption_provider ⇒ Object
change default encryption_provider.
160 161 162 |
# File 'lib/sorcery/model.rb', line 160 def custom_encryption_provider @custom_encryption_provider end |
#email_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def email_attribute_name @email_attribute_name end |
#encryption_algorithm ⇒ Object
change default encryption_provider.
160 161 162 |
# File 'lib/sorcery/model.rb', line 160 def encryption_algorithm @encryption_algorithm end |
#encryption_key ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def encryption_key @encryption_key end |
#encryption_provider ⇒ Object (readonly)
change default encryption_provider.
160 161 162 |
# File 'lib/sorcery/model.rb', line 160 def encryption_provider @encryption_provider end |
#password_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def password_attribute_name @password_attribute_name end |
#salt_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def salt_attribute_name @salt_attribute_name end |
#salt_join_token ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def salt_join_token @salt_join_token end |
#stretches ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def stretches @stretches end |
#subclasses_inherit_config ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def subclasses_inherit_config @subclasses_inherit_config end |
#submodules ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def submodules @submodules end |
#username_attribute_name ⇒ Object
change default username attribute, for example, to use :email as the login.
146 147 148 |
# File 'lib/sorcery/model.rb', line 146 def username_attribute_name @username_attribute_name end |
Instance Method Details
#reset! ⇒ Object
Resets all configuration options to their default values.
186 187 188 189 190 |
# File 'lib/sorcery/model.rb', line 186 def reset! @defaults.each do |k,v| instance_variable_set(k,v) end end |