method
thread_mattr_writer
v5.1.7 -
Show latest stable
- Class:
Module
thread_mattr_writer(*syms)public
Defines a per-thread class attribute and creates a class and instance writer methods to allow assignment to the attribute.
module Current thread_mattr_writer :user end Current.user = "DHH" Thread.current[:attr_Current_user] # => "DHH"
If you want to opt out of the creation of the instance writer method, pass instance_writer: false or instance_accessor: false.
class Current thread_mattr_writer :user, instance_writer: false end Current.new.user = "DHH" # => NoMethodError