Class: Reek::ClassContext
Instance Attribute Summary
Attributes inherited from CodeContext
#name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from CodeContext
#matches?, #method_missing
Constructor Details
#initialize(outer, name, superclass = nil) ⇒ ClassContext
Returns a new instance of ClassContext.
18
19
20
21
22
23
24
|
# File 'lib/reek/class_context.rb', line 18
def initialize(outer, name, superclass = nil)
super(outer, nil)
@name = name
@superclass = superclass
@parsed_methods = []
@instance_variables = Set.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Reek::CodeContext
Instance Method Details
#find_module(modname) ⇒ Object
30
31
32
33
|
# File 'lib/reek/class_context.rb', line 30
def find_module(modname)
return nil unless myself
@myself.const_or_nil(modname.to_s)
end
|
#is_overriding_method?(name) ⇒ Boolean
35
36
37
38
|
# File 'lib/reek/class_context.rb', line 35
def is_overriding_method?(name)
return false unless myself
@myself.is_overriding_method?(name.to_s)
end
|
#is_struct? ⇒ Boolean
40
41
42
|
# File 'lib/reek/class_context.rb', line 40
def is_struct?
@superclass == [:const, :Struct]
end
|
26
27
28
|
# File 'lib/reek/class_context.rb', line 26
def myself
@myself ||= @outer.find_module(@name)
end
|
#num_methods ⇒ Object
44
45
46
|
# File 'lib/reek/class_context.rb', line 44
def num_methods
@parsed_methods.length
end
|
#outer_name ⇒ Object
56
57
58
|
# File 'lib/reek/class_context.rb', line 56
def outer_name
"#{@outer.outer_name}#{@name}#"
end
|
#record_instance_variable(sym) ⇒ Object
48
49
50
|
# File 'lib/reek/class_context.rb', line 48
def record_instance_variable(sym)
@instance_variables << Name.new(sym)
end
|
#record_method(name) ⇒ Object
52
53
54
|
# File 'lib/reek/class_context.rb', line 52
def record_method(name)
@parsed_methods << name.to_s
end
|
60
61
62
|
# File 'lib/reek/class_context.rb', line 60
def to_s
"#{@outer.outer_name}#{@name}"
end
|
#variable_names ⇒ Object
64
65
66
|
# File 'lib/reek/class_context.rb', line 64
def variable_names
@instance_variables
end
|