Class: Class
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#mongo_thread_local_accessor(name, options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/mongo/util/core_ext.rb', line 64 def mongo_thread_local_accessor name, = {} m = Module.new m.module_eval do class_variable_set :"@@#{name}", Hash.new {|h,k| h[k] = [:default] } end m.module_eval %{ def #{name} @@#{name}[Thread.current.object_id] end def #{name}=(val) @@#{name}[Thread.current.object_id] = val end } class_eval do include m extend m end end |