Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add mongo_mapper to supported ORMs

  • Loading branch information...
commit d0e7400de12274f9d29a972f49949b855daa86ab 1 parent 88140ef
Tony Pitale tpitale authored
Showing with 8 additions and 4 deletions.
  1. +7 −3 lib/simplest_auth/model.rb
  2. +1 −1  lib/simplest_auth/version.rb
10 lib/simplest_auth/model.rb
View
@@ -8,7 +8,7 @@ def self.included(base)
attr_accessor :password, :password_confirmation
end
- if base.active_record?
+ if base.active_record? || base.mongo_mapper?
base.class_eval do
before_save :hash_password, :if => :password_required?
end
@@ -28,10 +28,14 @@ def data_mapper?
defined?(DataMapper)
end
+ def mongo_mapper?
+ defined?(MongoMapper)
+ end
+
def authenticate(email, password)
if active_record?
klass = find_by_email(email)
- elsif data_mapper?
+ elsif data_mapper? || mongo_mapper?
klass = first(:email => email)
end
@@ -46,7 +50,7 @@ def authenticate(#{ident}, password)
(klass && klass.authentic?(password)) ? klass : nil
end
EOM
- elsif data_mapper?
+ elsif data_mapper? || mongo_mapper?
instance_eval <<-EOM
def authenticate(#{ident}, password)
klass = first(:#{ident} => #{ident})
2  lib/simplest_auth/version.rb
View
@@ -3,7 +3,7 @@ module Version
MAJOR = 0
MINOR = 2
- TINY = 2
+ TINY = 5
def self.to_s # :nodoc:
[MAJOR, MINOR, TINY].join('.')
Please sign in to comment.
Something went wrong with that request. Please try again.