Netzke::Core::Masquerading

Public Instance Methods

authority_level() click to toggle source

Who are we acting as?

# File lib/netzke/core/masquerading.rb, line 18
def authority_level
  if session[:masq_world]
    :world
  elsif session[:masq_role]
    [:role, session[:masq_role]]
  elsif session[:masq_user]
    [:user, session[:masq_user]]
  elsif session[:netzke_user_id]
    [:self, session[:netzke_user_id]]
  else
    :none # or nil ?
  end
end
masquerade_as(authority_level, authority_id = true) click to toggle source

Example:

masquarade_as(:role, 2)
masquarade_as(:user, 4)
masquarade_as(:world)
# File lib/netzke/core/masquerading.rb, line 8
def masquerade_as(authority_level, authority_id = true)
  reset_masquerading
  session.merge!(:"masq_#{authority_level}" => authority_id)
end
reset_masquerading() click to toggle source
# File lib/netzke/core/masquerading.rb, line 13
def reset_masquerading
  session[:masq_world] = session[:masq_role] = session[:masq_user] = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.