Module: Multiauth::Helpers
- Defined in:
- lib/multiauth/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/multiauth/helpers.rb', line 3 def self.included(base) base.class_eval do helper_method :current_user, :logged_in? end end |
Instance Method Details
#current_user ⇒ Object
14 15 16 |
# File 'lib/multiauth/helpers.rb', line 14 def current_user @current_user ||= User.first(:_id => session[:user]) if session[:user] end |
#current_user=(new_user) ⇒ Object
9 10 11 12 |
# File 'lib/multiauth/helpers.rb', line 9 def current_user=(new_user) session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id @current_user = new_user end |
#logged_in? ⇒ Boolean
18 19 20 |
# File 'lib/multiauth/helpers.rb', line 18 def logged_in? !!self.current_user end |