Sha256: 60c20eade4bafd3743a3b856351dce66115ec2d0389ed9f7da2d719253a73e5b
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module Sorcery module Model module Adapters module MongoMapper extend ActiveSupport::Concern included do extend Sorcery::Model end def increment(attr) self.class.increment(id, attr => 1) end def sorcery_save(options = {}) if options.delete(:raise_on_failure) && options[:validate] != false save! options else save options end end def update_many_attributes(attrs) update_attributes(attrs) end module ClassMethods def credential_regex(credential) return { :$regex => /^#{Regexp.escape(credential)}$/i } if (@sorcery_config.downcase_username_before_authenticating) return credential end 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 def find_by_id(id) find(id) end def find_by_activation_token(token) where(sorcery_config.activation_token_attribute_name => token).first end def transaction(&blk) tap(&blk) end def find_by_sorcery_token(token_attr_name, token) where(token_attr_name => token).first end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sorcery-0.8.6 | lib/sorcery/model/adapters/mongo_mapper.rb |