Module: CanTango::Api::Masquerade::User
- Defined in:
- lib/cantango/masquerade/api/masquerade/user.rb
Instance Attribute Summary collapse
-
#active_user ⇒ Object
readonly
Returns the value of attribute active_user.
-
#masquerading ⇒ Object
readonly
Returns the value of attribute masquerading.
Instance Method Summary collapse
- #masquerade_as(user) ⇒ Object
- #masquerading? ⇒ Boolean (also: #masquerade?)
- #stop_masquerade ⇒ Object
Instance Attribute Details
#active_user ⇒ Object (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 |
#masquerading ⇒ Object (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?
17 18 19 |
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 17 def masquerading? !@masquerading.nil? end |
#stop_masquerade ⇒ Object
12 13 14 15 |
# File 'lib/cantango/masquerade/api/masquerade/user.rb', line 12 def stop_masquerade @active_user, @masquerading = nil, nil self end |