Class: Sorcery::Model::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfig

encryption algorithm name. See ‘encryption_algorithm=’ below for available options.



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/sorcery/model.rb', line 236

def initialize
  @defaults = {
    :@submodules                           => [],
    :@username_attribute_names              => [:email],
    :@password_attribute_name              => :password,
    :@downcase_username_before_authenticating => false,
    :@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_configObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def after_config
  @after_config
end

#before_authenticateObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def before_authenticate
  @before_authenticate
end

#crypted_password_attribute_nameObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def crypted_password_attribute_name
  @crypted_password_attribute_name
end

#custom_encryption_providerObject

an array of method names to call after configuration by user. used internally.



231
232
233
# File 'lib/sorcery/model.rb', line 231

def custom_encryption_provider
  @custom_encryption_provider
end

#downcase_username_before_authenticatingObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def downcase_username_before_authenticating
  @downcase_username_before_authenticating
end

#email_attribute_nameObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def email_attribute_name
  @email_attribute_name
end

#encryption_algorithmObject

an array of method names to call after configuration by user. used internally.



231
232
233
# File 'lib/sorcery/model.rb', line 231

def encryption_algorithm
  @encryption_algorithm
end

#encryption_keyObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def encryption_key
  @encryption_key
end

#encryption_providerObject (readonly)

an array of method names to call after configuration by user. used internally.



231
232
233
# File 'lib/sorcery/model.rb', line 231

def encryption_provider
  @encryption_provider
end

#password_attribute_nameObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def password_attribute_name
  @password_attribute_name
end

#salt_attribute_nameObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def salt_attribute_name
  @salt_attribute_name
end

#salt_join_tokenObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def salt_join_token
  @salt_join_token
end

#stretchesObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def stretches
  @stretches
end

#subclasses_inherit_configObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def subclasses_inherit_config
  @subclasses_inherit_config
end

#submodulesObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def submodules
  @submodules
end

#username_attribute_namesObject

change default username attribute, for example, to use :email



204
205
206
# File 'lib/sorcery/model.rb', line 204

def username_attribute_names
  @username_attribute_names
end

Instance Method Details

#reset!Object

Resets all configuration options to their default values.



259
260
261
262
263
# File 'lib/sorcery/model.rb', line 259

def reset!
  @defaults.each do |k,v|
    instance_variable_set(k,v)
  end
end