Class: Reek::ModuleContext

Inherits:
CodeContext show all
Defined in:
lib/reek/module_context.rb

Instance Attribute Summary

Attributes inherited from CodeContext

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CodeContext

#matches?, #method_missing, #num_methods, #to_s

Constructor Details

#initialize(outer, name) ⇒ ModuleContext

Returns a new instance of ModuleContext.



11
12
13
14
# File 'lib/reek/module_context.rb', line 11

def initialize(outer, name)
  super(outer, nil)
  @name = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Reek::CodeContext

Class Method Details

.create(outer, exp) ⇒ Object



6
7
8
9
# File 'lib/reek/module_context.rb', line 6

def ModuleContext.create(outer, exp)
  res = Name.resolve(exp[1], outer)
  ModuleContext.new(res[0], res[1])
end

Instance Method Details

#find_module(modname) ⇒ Object



20
21
22
23
# File 'lib/reek/module_context.rb', line 20

def find_module(modname)
  return nil unless myself
  @myself.const_or_nil(modname.to_s)
end

#myselfObject



16
17
18
# File 'lib/reek/module_context.rb', line 16

def myself
  @myself ||= @outer.find_module(@name)
end

#outer_nameObject



25
26
27
# File 'lib/reek/module_context.rb', line 25

def outer_name
  "#{@outer.outer_name}#{@name}::"
end

#variable_namesObject



29
30
31
# File 'lib/reek/module_context.rb', line 29

def variable_names
  []
end