Module: CurrentUserId

Defined in:
lib/sixarm_ruby_current_user_id.rb

Overview

Please see README

Instance Method Summary collapse

Instance Method Details

#current_user_id(ops = {}) ⇒ Object

Get the current user id in the Rails session array.

The current user id is memoized as @current_user_id. To reload, pass :reload => true

Return the session’s current user id.



16
17
18
19
# File 'lib/sixarm_ruby_current_user_id.rb', line 16

def current_user_id(ops={})
  if ops[:reload] then @current_user_id=nil end
  @current_user_id ||= session[:current_user_id]
end

#current_user_id=(id) ⇒ Object

Set the current user id in the Rails session array. Return the current user id, suitable for chaining.



32
33
34
# File 'lib/sixarm_ruby_current_user_id.rb', line 32

def current_user_id=(id)
  @current_user_id=session[:current_user_id]=id
end

#current_user_id?Boolean

Is there a current user id in the Rails session array?

Returns:

  • (Boolean)


24
25
26
# File 'lib/sixarm_ruby_current_user_id.rb', line 24

def current_user_id?
  return session[:current_user_id] ? true : false
end