Class: ClassMetrix::Services::ScopeResolver
- Inherits:
-
Object
- Object
- ClassMetrix::Services::ScopeResolver
- Defined in:
- lib/class_metrix/services/scope_resolver.rb
Overview
Determines what should be scanned based on extraction config
Instance Method Summary collapse
-
#initialize(config) ⇒ ScopeResolver
constructor
A new instance of ScopeResolver.
- #resolve_constant_scope(klass) ⇒ Object
- #resolve_method_scope(klass) ⇒ Object
Constructor Details
#initialize(config) ⇒ ScopeResolver
Returns a new instance of ScopeResolver.
7 8 9 |
# File 'lib/class_metrix/services/scope_resolver.rb', line 7 def initialize(config) @config = config end |
Instance Method Details
#resolve_constant_scope(klass) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/class_metrix/services/scope_resolver.rb', line 26 def resolve_constant_scope(klass) constants = {} # : Hash[String, untyped] # Always include the class's own constants constants.merge!(collect_own_constants(klass)) constants.merge!(collect_inherited_constants(klass)) if @config.include_inheritance? constants.merge!(collect_module_constants(klass)) if @config.include_modules? constants.merge!(collect_private_constants(klass)) if @config.include_private? constants end |
#resolve_method_scope(klass) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/class_metrix/services/scope_resolver.rb', line 11 def resolve_method_scope(klass) methods = Set.new # Always include the class's own methods methods.merge(klass.singleton_methods(false)) methods.merge(collect_inherited_methods(klass)) if @config.include_inheritance? methods.merge(collect_module_methods(klass)) if @config.include_modules? methods.merge(collect_private_methods(klass)) if @config.include_private? methods.to_a.sort end |