Module: ThreadLocalVarAccessors::ClassMethods
- Defined in:
- lib/thread_local_var_accessors.rb
Instance Method Summary collapse
- #tlv_accessor(*names) ⇒ Object
- #tlv_reader(*names) ⇒ Object
-
#tlv_writer(*names) ⇒ Object
like attr_writer, but supports using block-values, which receive the current value, returning the new value.
Instance Method Details
#tlv_accessor(*names) ⇒ Object
224 225 226 227 |
# File 'lib/thread_local_var_accessors.rb', line 224 def tlv_accessor(*names) tlv_reader(*names) tlv_writer(*names) end |
#tlv_reader(*names) ⇒ Object
208 209 210 211 212 |
# File 'lib/thread_local_var_accessors.rb', line 208 def tlv_reader(*names) names.each do |name| define_method(name.to_sym) { tlv_get(name) } end end |
#tlv_writer(*names) ⇒ Object
like attr_writer, but supports using block-values, which receive the current value, returning the new value
216 217 218 219 220 221 222 |
# File 'lib/thread_local_var_accessors.rb', line 216 def tlv_writer(*names) names.each do |name| define_method("#{name}=".to_sym) do |new_value, &block| tlv_set(name, new_value, &block) end end end |