Permalink
Browse files

add mongo_mapper to supported ORMs

  • Loading branch information...
1 parent 88140ef commit d0e7400de12274f9d29a972f49949b855daa86ab @tpitale tpitale committed Dec 15, 2009
Showing with 8 additions and 4 deletions.
  1. +7 −3 lib/simplest_auth/model.rb
  2. +1 −1 lib/simplest_auth/version.rb
View
10 lib/simplest_auth/model.rb
@@ -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})
View
2 lib/simplest_auth/version.rb
@@ -3,7 +3,7 @@ module Version
MAJOR = 0
MINOR = 2
- TINY = 2
+ TINY = 5
def self.to_s # :nodoc:
[MAJOR, MINOR, TINY].join('.')

0 comments on commit d0e7400

Please sign in to comment.