Sha256: 6f915bacf90dbdf84d2522aa3917c70e631036e487aa8281015df7c1492daaad
Contents?: true
Size: 871 Bytes
Versions: 1
Compression:
Stored size: 871 Bytes
Contents
# -*- coding: utf-8 -*- =begin rdoc Please see README.rdoc =end require 'sixarm_ruby_current_user_id' module CurrentUser # Get the current user. # # This calls User.find with the current_user_id # # The current user is memoized as @current_user. # To reload, pass :reload => true # # Return the current user, # or nil if the current user id is not set, # or raise an exception if the current iser id is invalid def current_user(ops={}) if ops[:reload] then @current_user=nil end @current_user ||= (current_user_id ? User.find(current_user_id) : nil) end # Is there a current user in the Rails session? def current_user? !!self.current_user end # Set the current user # Return the current user def current_user=(user) self.current_user_id = (user ? user.id : nil) @current_user = user end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sixarm_ruby_current_user-1.4.0 | lib/sixarm_ruby_current_user.rb |