Module: Guideline::Parser::Moduleable

Included in:
AbcComplexityChecker::AbcParser, UnusedMethodChecker::MethodDefinitionChecker
Defined in:
lib/guideline/parser/moduleable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/guideline/parser/moduleable.rb', line 4

def self.included(base)
  base.class_eval do
    interesting_nodes :class, :module

    add_callback :start_class do |node|
      modules << node.class_name.to_s
    end

    add_callback :start_module do |node|
      modules << node.module_name.to_s
    end

    add_callback :end_class do |node|
      modules.pop
    end

    add_callback :end_module do |node|
      modules.pop
    end
  end
end

Instance Method Details

#current_module_nameObject



26
27
28
# File 'lib/guideline/parser/moduleable.rb', line 26

def current_module_name
  modules.join("::")
end

#modulesObject



30
31
32
# File 'lib/guideline/parser/moduleable.rb', line 30

def modules
  @moduels ||= []
end