Class: Reek::BlockContext
Instance Attribute Summary
Attributes inherited from CodeContext
#name
Instance Method Summary
collapse
Methods inherited from CodeContext
#matches?, #method_missing, #num_methods, #to_s
Constructor Details
#initialize(outer, exp) ⇒ BlockContext
Returns a new instance of BlockContext.
26
27
28
29
30
31
32
33
|
# File 'lib/reek/block_context.rb', line 26
def initialize(outer, exp)
super
@name = Name.new('block')
@parameters = exp[0] if exp
@parameters ||= []
@parameters.extend(ParameterSet)
@local_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
#has_parameter(name) ⇒ Object
39
40
41
|
# File 'lib/reek/block_context.rb', line 39
def has_parameter(name)
@parameters.include?(name) or @outer.has_parameter(name)
end
|
#inside_a_block? ⇒ Boolean
35
36
37
|
# File 'lib/reek/block_context.rb', line 35
def inside_a_block?
true
end
|
#nested_block? ⇒ Boolean
43
44
45
|
# File 'lib/reek/block_context.rb', line 43
def nested_block?
@outer.inside_a_block?
end
|
#outer_name ⇒ Object
51
52
53
|
# File 'lib/reek/block_context.rb', line 51
def outer_name
"#{@outer.outer_name}#{@name}/"
end
|
#record_local_variable(sym) ⇒ Object
47
48
49
|
# File 'lib/reek/block_context.rb', line 47
def record_local_variable(sym)
@local_variables << Name.new(sym)
end
|
#variable_names ⇒ Object
55
56
57
|
# File 'lib/reek/block_context.rb', line 55
def variable_names
@parameters.names + @local_variables.to_a
end
|