Sha256: e80976e6c7829f97cb00c0bd5eae7cc94f1f6d898fd5844276d3b61a7491adfc

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

module Devise
  module Orm
    module MongoMapper
      module InstanceMethods
        def save(options={})
          if options == false
            super(:validate => false)
          else
            super
          end
        end
      end

      def self.included_modules_hook(klass)
        klass.send :extend,  self
        klass.send :include, InstanceMethods
        yield

        klass.devise_modules.each do |mod|
          klass.send(mod) if klass.respond_to?(mod)
        end
      end
      
      def find(*args)
        case args.first
        when :first, :all
          send(args.shift, *args)
        else
          super
        end
      end
      
      include Devise::Schema

      # 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::EmbeddedDocument::ClassMethods.send(:include, Devise::Models)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise-1.0.7 lib/devise/orm/mongo_mapper.rb
devise-1.0.6 lib/devise/orm/mongo_mapper.rb
devise-1.0.5 lib/devise/orm/mongo_mapper.rb
devise-1.0.4 lib/devise/orm/mongo_mapper.rb
devise-1.0.3 lib/devise/orm/mongo_mapper.rb