Permalink
Browse files

Remove deprecation warning, extract SessionSerializer and release new…

… version.
  • Loading branch information...
1 parent 35370e9 commit e51e19c08ccf44e3bfb360fdb1fb765139bd025e @josevalim josevalim committed Dec 7, 2009
Showing with 28 additions and 27 deletions.
  1. +10 −1 CHANGELOG.rdoc
  2. +3 −8 lib/devise/models.rb
  3. +14 −12 lib/devise/models/authenticatable.rb
  4. +0 −5 lib/devise/rails/routes.rb
  5. +1 −1 lib/devise/version.rb
View
11 CHANGELOG.rdoc
@@ -1,3 +1,12 @@
+== 0.7.0
+
+* deprecations
+ * :authenticatable is not included by default anymore
+
+* enhancements
+ * Improve loading process
+ * Extract SessionSerializer from Authenticatable
+
== 0.6.3
* bug fix
@@ -19,7 +28,7 @@
== 0.6.0
* deprecations
- * :authenticatable is not included by default anymore
+ * :authenticatable is still included by default, but yields a deprecation warning
* enhancements
* Added DataMapper support
View
11 lib/devise/models.rb
@@ -3,7 +3,8 @@ module Models
autoload :Authenticatable, 'devise/models/authenticatable'
autoload :Confirmable, 'devise/models/confirmable'
autoload :Recoverable, 'devise/models/recoverable'
- autoload :Rememberable, 'devise/models/rememberable'
+ autoload :Rememberable, 'devise/models/rememberable'
+ autoload :SessionSerializer, 'devise/models/authenticatable'
autoload :Timeoutable, 'devise/models/timeoutable'
autoload :Trackable, 'devise/models/trackable'
autoload :Validatable, 'devise/models/validatable'
@@ -77,19 +78,13 @@ def #{accessor}=(value)
# devise :all, :except => :recoverable
#
def devise(*modules)
- # TODO Add this check in future versions
- # raise "You need to give at least one Devise module" if modules.empty?
+ raise "You need to give at least one Devise module" if modules.empty?
options = modules.extract_options!
modules = Devise.all if modules.include?(:all)
modules -= Array(options.delete(:except))
modules = Devise::ALL & modules
- if !modules.include?(:authenticatable)
- modules = [:authenticatable] | modules
- ActiveSupport::Deprecation.warn ":authenticatable won't be included by default in devise in future versions, please add it", caller[0,10]
- end
-
Devise.orm_class.included_modules_hook(self, modules) do
modules.each do |m|
devise_modules << m.to_sym
View
26 lib/devise/models/authenticatable.rb
@@ -3,6 +3,19 @@
module Devise
module Models
+ module SessionSerializer
+ # Hook to serialize user into session. Overwrite if you want.
+ def serialize_into_session(record)
+ [record.class, record.id]
+ end
+
+ # Hook to serialize user from session. Overwrite if you want.
+ def serialize_from_session(keys)
+ klass, id = keys
+ raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
+ klass.find(:first, :conditions => { :id => id })
+ end
+ end
# Authenticable Module, responsible for encrypting password and validating
# authenticity of a user while signing in.
@@ -32,6 +45,7 @@ module Authenticatable
def self.included(base)
base.class_eval do
extend ClassMethods
+ extend SessionSerializer
attr_reader :password
attr_accessor :password_confirmation
@@ -71,18 +85,6 @@ def authenticate(attributes={})
valid_for_authentication(resource, attributes) if resource
end
- # Hook to serialize user into session. Overwrite if you want.
- def serialize_into_session(record)
- [record.class, record.id]
- end
-
- # Hook to serialize user from session. Overwrite if you want.
- def serialize_from_session(keys)
- klass, id = keys
- raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
- klass.find(:first, :conditions => { :id => id })
- end
-
# Returns the class for the configured encryptor.
def encryptor_class
@encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)
View
5 lib/devise/rails/routes.rb
@@ -79,11 +79,6 @@ class Mapper #:doc:
def devise_for(*resources)
options = resources.extract_options!
- if singular = options.delete(:singular)
- ActiveSupport::Deprecation.warn ":singular is deprecated in devise_for, use :scope instead."
- options[:scope] = singular
- end
-
resources.map!(&:to_sym)
resources.each do |resource|
mapping = Devise::Mapping.new(resource, options.dup)
View
2 lib/devise/version.rb
@@ -1,3 +1,3 @@
module Devise
- VERSION = "0.6.3".freeze
+ VERSION = "0.7.0".freeze
end

0 comments on commit e51e19c

Please sign in to comment.