Module: Sorcery::Model::Adapters::MongoMapper::ClassMethods

Defined in:
lib/sorcery/model/adapters/mongo_mapper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) credential_regex(credential)



22
23
24
25
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 22

def credential_regex(credential)
  return { :$regex =>  /^#{credential}$/i  }  if (@sorcery_config.downcase_username_before_authenticating)
  return credential
end

- (Object) find_by_activation_token(token)



39
40
41
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 39

def find_by_activation_token(token)
  where(sorcery_config.activation_token_attribute_name => token).first
end

- (Object) find_by_credentials(credentials)



27
28
29
30
31
32
33
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 27

def find_by_credentials(credentials)
  @sorcery_config.username_attribute_names.each do |attribute|
    @user = where(attribute => credential_regex(credentials[0])).first
    break if @user
  end
  @user
end

- (Object) find_by_id(id)



35
36
37
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 35

def find_by_id(id)
  find(id)
end

- (Object) find_by_sorcery_token(token_attr_name, token)



47
48
49
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 47

def find_by_sorcery_token(token_attr_name, token)
  where(token_attr_name => token).first
end

- (Object) transaction(&blk)



43
44
45
# File 'lib/sorcery/model/adapters/mongo_mapper.rb', line 43

def transaction(&blk)
  tap(&blk)
end