Class: DeadCodeDetector::BaseMethodWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dead_code_detector/base_method_wrapper.rb

Direct Known Subclasses

ClassMethodWrapper, InstanceMethodWrapper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ BaseMethodWrapper

Returns a new instance of BaseMethodWrapper.



6
7
8
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 6

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 4

def klass
  @klass
end

Class Method Details

.track_method(klass, method_name) ⇒ Object



11
12
13
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 11

def track_method(klass, method_name)
  DeadCodeDetector.config.storage.delete(record_key(klass.name), method_name)
end

.unwrap_method(klass, original_method) ⇒ Object

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 15

def unwrap_method(klass, original_method)
  raise NotImplementedError
end

Instance Method Details

#clear_cacheObject



30
31
32
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 30

def clear_cache
  DeadCodeDetector.config.storage.clear(self.class.record_key(klass.name))
end

#number_of_tracked_methodsObject



26
27
28
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 26

def number_of_tracked_methods
  default_methods.count
end

#refresh_cacheObject



34
35
36
37
38
39
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 34

def refresh_cache
  clear_cache
  if default_methods.any?
    DeadCodeDetector.config.storage.add(self.class.record_key(klass.name), default_methods)
  end
end

#wrap_methods!Object



20
21
22
23
24
# File 'lib/dead_code_detector/base_method_wrapper.rb', line 20

def wrap_methods!
  potentially_unused_methods.each do |method_name|
    wrap_method(get_method(method_name))
  end
end