class DeadCodeDetector::BaseMethodWrapper

Attributes

klass[R]

Public Class Methods

new(klass) click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 6
def initialize(klass)
  @klass = klass
end
track_method(klass, method_name) click to toggle source
# 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) click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 15
def unwrap_method(klass, original_method)
  raise NotImplementedError
end

Public Instance Methods

clear_cache() click to toggle source
# 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_methods() click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 26
def number_of_tracked_methods
  default_methods.count
end
refresh_cache() click to toggle source
# 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!() click to toggle source
# 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

Private Instance Methods

default_methods() click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 43
def default_methods
  raise NotImplementedError
end
get_method(method_name) click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 47
def get_method(method_name)
  raise NotImplementedError
end
owned_method?(method_name) click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 55
def owned_method?(method_name)
  raise NotImplementedError
end
potentially_unused_methods() click to toggle source

Due to caching, new methods won't show up automatically in this call

# File lib/dead_code_detector/base_method_wrapper.rb, line 60
def potentially_unused_methods
  stored_methods = DeadCodeDetector.config.storage.get(self.class.record_key(klass.name))

  stored_methods & default_methods.map(&:to_s)
end
wrap_method(original_method) click to toggle source
# File lib/dead_code_detector/base_method_wrapper.rb, line 51
def wrap_method(original_method)
  raise NotImplementedError
end