Permalink
Browse files

Fix deprecation warnings with ActiveModel 3.2.

  • Loading branch information...
1 parent ded8cba commit 3a14df9760421cec7b2dd25025f683c538276aa1 @cee-dub cee-dub committed Jan 30, 2012
Showing with 48 additions and 55 deletions.
  1. +19 −22 lib/simplest_auth/session.rb
  2. +29 −33 lib/simplest_auth/sessions_controller.rb
@@ -28,33 +28,30 @@ def user_class
end
end
- module InstanceMethods
- def initialize(attributes = {})
- attributes.each {|k,v| send("#{k}=", v) }
- end
-
- def user_class
- self.class.user_class
- end
+ def initialize(attributes = {})
+ attributes.each {|k,v| send("#{k}=", v) }
+ end
- def user
- @user ||= user_class.authenticate(email, password)
- end
+ def user_class
+ self.class.user_class
+ end
- def persisted?
- false
- end
+ def user
+ @user ||= user_class.authenticate(email, password)
+ end
- private
+ def persisted?
+ false
+ end
- def user_exists_for_credentials
- errors.add(:base, "#{user_class} not found for supplied credentials") unless user.present?
- end
+ private
- def credentials_supplied?
- email.present? && password.present?
- end
+ def user_exists_for_credentials
+ errors.add(:base, "#{user_class} not found for supplied credentials") unless user.present?
end
+ def credentials_supplied?
+ email.present? && password.present?
+ end
end
-end
+end
@@ -14,49 +14,45 @@ def session_class_name
end
- module InstanceMethods
-
- def new
- @session = session_class.new
- end
-
- def create
- sign_user_in_or_render
- end
-
- def destroy
- sign_user_out
- end
+ def new
+ @session = session_class.new
+ end
- private
+ def create
+ sign_user_in_or_render
+ end
- def sign_user_in_or_render(options = {})
- message = options[:message] || 'You have signed in successfully'
- redirect_url = options[:url] || root_url
+ def destroy
+ sign_user_out
+ end
- @session = session_class.new(params[:session])
- if @session.valid?
- self.current_user = @session.user
- flash[:notice] = message
- redirect_to redirect_url
- else
- render :new
- end
- end
+ private
- def sign_user_out(options = {})
- message = options[:message] || 'You have signed out'
- redirect_url = options[:url] || root_url
+ def sign_user_in_or_render(options = {})
+ message = options[:message] || 'You have signed in successfully'
+ redirect_url = options[:url] || root_url
- self.current_user = nil
+ @session = session_class.new(params[:session])
+ if @session.valid?
+ self.current_user = @session.user
flash[:notice] = message
redirect_to redirect_url
+ else
+ render :new
end
+ end
- def session_class
- self.class.session_class_name.constantize
- end
+ def sign_user_out(options = {})
+ message = options[:message] || 'You have signed out'
+ redirect_url = options[:url] || root_url
+
+ self.current_user = nil
+ flash[:notice] = message
+ redirect_to redirect_url
+ end
+ def session_class
+ self.class.session_class_name.constantize
end
end

0 comments on commit 3a14df9

Please sign in to comment.