Module: Mongoid::Userstamp::User::ClassMethods
- Defined in:
- lib/mongoid/userstamp/user.rb
Instance Method Summary collapse
Instance Method Details
#current ⇒ Object
13 14 15 |
# File 'lib/mongoid/userstamp/user.rb', line 13 def current RequestStore.store[:user] end |
#current=(value) ⇒ Object
17 18 19 |
# File 'lib/mongoid/userstamp/user.rb', line 17 def current=(value) RequestStore.store[:user] = value end |
#do_as(user, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mongoid/userstamp/user.rb', line 21 def do_as(user, &block) old = self.current begin self.current = user response = block.call unless block.nil? ensure self.current = old end response end |