trabajo-afectivo/lib/user_info.rb

28 lines
594 B
Ruby
Raw Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
2012-04-10 14:30:10 +00:00
module UserInfo
def self.current_user_id
2012-04-10 14:30:10 +00:00
Thread.current[:user_id]
end
2015-04-11 15:26:21 +00:00
2012-04-10 14:30:10 +00:00
def self.current_user_id=(user_id)
Thread.current[:user_id] = user_id
Thread.current[:assets] = UserInfo::Assets.new(user_id)
end
def self.assets
Thread.current[:assets]
2012-04-10 14:30:10 +00:00
end
def self.ensure_current_user_id
if UserInfo.current_user_id.nil?
UserInfo.current_user_id = 1
reset_current_user_id = true
end
yield
ensure
UserInfo.current_user_id = nil if reset_current_user_id
end
end