Module: CanTango::Api::Masquerade::User

Defined in:
lib/cantango/masquerade/api/masquerade/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#active_userObject (readonly)

Returns the value of attribute active_user.



3
4
5
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 3

def active_user
  @active_user
end

#masqueradingObject (readonly)

Returns the value of attribute masquerading.



3
4
5
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 3

def masquerading
  @masquerading
end

Instance Method Details

#masquerade_as(user) ⇒ Object



5
6
7
8
9
10
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 5

def masquerade_as user
  raise "Must be a registered type of user, was: #{user}" unless valid_user? user
  @masquerading = true
  @active_user = user
  self
end

#masquerading?Boolean Also known as: masquerade?

Returns:

  • (Boolean)


17
18
19
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 17

def masquerading?
  !@masquerading.nil?
end

#stop_masqueradeObject



12
13
14
15
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 12

def stop_masquerade
  @active_user, @masquerading = nil, nil
  self
end