Skip to content

Commit

Permalink
Mongomapper ORM now converts DateTime to Time.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 18, 2009
1 parent 680cb0f commit 4c81eca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rdoc
@@ -1,6 +1,11 @@
* bug fix
* MongoMapper now converts DateTime to Time

* enhancements
* [#35] Moved friendly_token to Devise
* Added Devise.all, so you can freeze your app strategies
* Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
in cases you don't want it be handlded automatically

== 0.5.2

Expand Down
9 changes: 7 additions & 2 deletions lib/devise.rb
Expand Up @@ -25,7 +25,7 @@ module Devise
:authlogic_sha512 => 128
}

# Used to encrypt password. Please generate one with rake secret
# Used to encrypt password. Please generate one with rake secret.
mattr_accessor :pepper
@@pepper = nil

Expand Down Expand Up @@ -64,10 +64,15 @@ def self.encryptor=(value)
mattr_accessor :orm
@@orm = :active_record

# Configure default options used in :all
# Configure default options used in :all.
mattr_accessor :all
@@all = Devise::ALL.dup

# Tells if devise should apply the schema in ORMs where devise declaration
# and schema belongs to the same class (as Datamapper and MongoMapper).
mattr_accessor :apply_schema
@@apply_schema = true

class << self
# Default way to setup Devise. Run script/generate devise_install to create
# a fresh initializer with all configuration values.
Expand Down
7 changes: 5 additions & 2 deletions lib/devise/orm/mongo_mapper.rb
Expand Up @@ -12,12 +12,15 @@ def self.included_modules_hook(klass, modules)

include Devise::Schema

# Tell how to apply schema methods.
# Tell how to apply schema methods. This automatically converts DateTime
# to Time, since MongoMapper does not recognize the former.
def apply_schema(name, type, options={})
return unless Devise.apply_schema
type = Time if type == DateTime
key name, type, options
end
end
end
end

MongoMapper::Document::ClassMethods.send(:include, Devise::Models)
MongoMapper::Document::ClassMethods.send(:include, Devise::Models)

0 comments on commit 4c81eca

Please sign in to comment.