Class: DiverDown::Trace::ModuleSet::ConstSourceLocationModuleSet

Inherits:
Object
  • Object
show all
Defined in:
lib/diver_down/trace/module_set/const_source_location_module_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths: []) ⇒ ConstSourceLocationModuleSet

Returns a new instance of ConstSourceLocationModuleSet.

Parameters:

  • paths (Array<String>, Set<String>) (defaults to: [])


8
9
10
# File 'lib/diver_down/trace/module_set/const_source_location_module_set.rb', line 8

def initialize(paths: [])
  @paths = paths.to_set
end

Instance Method Details

#include?(mod) ⇒ Boolean

Parameters:

  • mod (Module)

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/diver_down/trace/module_set/const_source_location_module_set.rb', line 14

def include?(mod)
  module_name = DiverDown::Helper.normalize_module_name(mod)

  path, = begin
    Object.const_source_location(module_name)
  rescue NameError, TypeError
    nil
  end

  path && @paths.include?(path)
end