Sha256: 77a1631eed197bcee0377918d14deb86a94001b72c3f74db5328dc9ac34a99d3
Contents?: true
Size: 748 Bytes
Versions: 1
Compression:
Stored size: 748 Bytes
Contents
# -*- encoding : utf-8 -*- module Mongoid module Userstamp module User extend ActiveSupport::Concern included do def current? !Thread.current[:user].nil? && self._id == Thread.current[:user]._id end end module ClassMethods def current Thread.current[:user] end def current=(value) Thread.current[:user] = value end 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid_userstamp-0.3.2 | lib/mongoid/userstamp/user.rb |