lib/bullet.rb in bullet-7.2.0 vs lib/bullet.rb in bullet-8.0.0

- old
+ new

@@ -146,45 +146,50 @@ def debug(title, message) puts "[Bullet][#{title}] #{message}" if ENV['BULLET_DEBUG'] == 'true' end def start_request - Thread.current[:bullet_start] = true - Thread.current[:bullet_notification_collector] = Bullet::NotificationCollector.new + Thread.current.thread_variable_set(:bullet_start, true) + Thread.current.thread_variable_set(:bullet_notification_collector, Bullet::NotificationCollector.new) - Thread.current[:bullet_object_associations] = Bullet::Registry::Base.new - Thread.current[:bullet_call_object_associations] = Bullet::Registry::Base.new - Thread.current[:bullet_possible_objects] = Bullet::Registry::Object.new - Thread.current[:bullet_impossible_objects] = Bullet::Registry::Object.new - Thread.current[:bullet_inversed_objects] = Bullet::Registry::Base.new - Thread.current[:bullet_eager_loadings] = Bullet::Registry::Association.new - Thread.current[:bullet_call_stacks] = Bullet::Registry::CallStack.new + Thread.current.thread_variable_set(:bullet_object_associations, Bullet::Registry::Base.new) + Thread.current.thread_variable_set(:bullet_call_object_associations, Bullet::Registry::Base.new) + Thread.current.thread_variable_set(:bullet_possible_objects, Bullet::Registry::Object.new) + Thread.current.thread_variable_set(:bullet_impossible_objects, Bullet::Registry::Object.new) + Thread.current.thread_variable_set(:bullet_inversed_objects, Bullet::Registry::Base.new) + Thread.current.thread_variable_set(:bullet_eager_loadings, Bullet::Registry::Association.new) + Thread.current.thread_variable_set(:bullet_call_stacks, Bullet::Registry::CallStack.new) - Thread.current[:bullet_counter_possible_objects] ||= Bullet::Registry::Object.new - Thread.current[:bullet_counter_impossible_objects] ||= Bullet::Registry::Object.new + unless Thread.current.thread_variable_get(:bullet_counter_possible_objects) + Thread.current.thread_variable_set(:bullet_counter_possible_objects, Bullet::Registry::Object.new) + end + + unless Thread.current.thread_variable_get(:bullet_counter_impossible_objects) + Thread.current.thread_variable_set(:bullet_counter_impossible_objects, Bullet::Registry::Object.new) + end end def end_request - Thread.current[:bullet_start] = nil - Thread.current[:bullet_notification_collector] = nil + Thread.current.thread_variable_set(:bullet_start, nil) + Thread.current.thread_variable_set(:bullet_notification_collector, nil) - Thread.current[:bullet_object_associations] = nil - Thread.current[:bullet_call_object_associations] = nil - Thread.current[:bullet_possible_objects] = nil - Thread.current[:bullet_impossible_objects] = nil - Thread.current[:bullet_inversed_objects] = nil - Thread.current[:bullet_eager_loadings] = nil + Thread.current.thread_variable_set(:bullet_object_associations, nil) + Thread.current.thread_variable_set(:bullet_call_object_associations, nil) + Thread.current.thread_variable_set(:bullet_possible_objects, nil) + Thread.current.thread_variable_set(:bullet_impossible_objects, nil) + Thread.current.thread_variable_set(:bullet_inversed_objects, nil) + Thread.current.thread_variable_set(:bullet_eager_loadings, nil) - Thread.current[:bullet_counter_possible_objects] = nil - Thread.current[:bullet_counter_impossible_objects] = nil + Thread.current.thread_variable_set(:bullet_counter_possible_objects, nil) + Thread.current.thread_variable_set(:bullet_counter_impossible_objects, nil) end def start? - enable? && Thread.current[:bullet_start] + enable? && Thread.current.thread_variable_get(:bullet_start) end def notification_collector - Thread.current[:bullet_notification_collector] + Thread.current.thread_variable_get(:bullet_notification_collector) end def notification? return unless start?