thread_mattr_accessor
module Current
# 定义当前线程中的类方法或实例方法, 可以有Current.user = 和Current.user方法
thread_mattr_accessor :user
Current.user = 'a'
Current.user => a
c = Current.new => undefined method `new' for Current:Module
end
class Current
# 定义当前线程中的类方法或实例方法, 可以有Current.user = 和Current.user方法
thread_mattr_accessor :user
Current.user = 'a'
Current.user => a
c = Current.new
c.user = 'b'
c.user => b
Tread.new { puts Current.user } => Current.user在新线程中没定义所以是nil
end