Class: BulletmarkRepairer::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/bulletmark_repairer/thread.rb

Class Method Summary collapse

Class Method Details

.clearObject



37
38
39
# File 'lib/bulletmark_repairer/thread.rb', line 37

def clear
  ::Thread.current[:bulletmark_repairer] = nil
end

.correctable_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/bulletmark_repairer/thread.rb', line 33

def correctable_method?(method_name)
  current(:loaded_methods).include?(method_name)
end

.current(key) ⇒ Object



8
9
10
# File 'lib/bulletmark_repairer/thread.rb', line 8

def current(key)
  touch(key)
end

.instance_variable_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bulletmark_repairer/thread.rb', line 22

def instance_variable_name?(name)
  current(:loaded_instance_variables).include?(name)
end

.memorize_associations(name:, method_type:, args:) ⇒ Object



12
13
14
# File 'lib/bulletmark_repairer/thread.rb', line 12

def memorize_associations(name:, method_type:, args:)
  current(:loaded_associations)[name][method_type].add(args)
end

.memorize_instance_variable_name(name:, value:) ⇒ Object



16
17
18
19
20
# File 'lib/bulletmark_repairer/thread.rb', line 16

def memorize_instance_variable_name(name:, value:)
  return unless value.is_a?(::ActiveRecord::Relation)

  current(:loaded_instance_variables).add("@#{name}")
end

.memorize_methods(method_name:, value:) ⇒ Object

TODO: Memorize methods with class



27
28
29
30
31
# File 'lib/bulletmark_repairer/thread.rb', line 27

def memorize_methods(method_name:, value:)
  return unless value.is_a?(::ActiveRecord::Associations::CollectionProxy) || value.is_a?(::ActiveRecord::Relation)

  current(:loaded_methods).add(method_name)
end