Module: Mongoid::Accountify::Account::ClassMethods

Defined in:
lib/mongoid/accountify/account.rb

Instance Method Summary collapse

Instance Method Details

#currentObject



14
15
16
# File 'lib/mongoid/accountify/account.rb', line 14

def current
  Thread.current[:account]
end

#current=(value) ⇒ Object



18
19
20
# File 'lib/mongoid/accountify/account.rb', line 18

def current=(value)
  Thread.current[:account] = value
end

#do_as(account, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mongoid/accountify/account.rb', line 22

def do_as(, &block)
  old = self.current

  begin
    self.current = 
    response = block.call unless block.nil?
  ensure
    self.current = old
  end

  response
end