Sha256: b0e71882a44c7d1fa4ba3d5399c1b07eb0be1be6d8fb9d647d97ea1dd5e7471d

Contents?: true

Size: 636 Bytes

Versions: 8

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true

module DiverDown
  module Trace
    class ModuleSet
      class ConstSourceLocationModuleSet
        # @param [Array<String>, Set<String>] paths
        def initialize(paths: [])
          @paths = paths.to_set
        end

        # @param [Module] mod
        # @return [Boolean]
        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
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
diver_down-0.0.1.alpha17 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha16 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha15 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha14 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha13 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha3 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha2 lib/diver_down/trace/module_set/const_source_location_module_set.rb
diver_down-0.0.1.alpha1 lib/diver_down/trace/module_set/const_source_location_module_set.rb