Class: Reek::SingletonMethodContext

Inherits:
MethodContext show all
Defined in:
lib/reek/singleton_method_context.rb

Instance Attribute Summary

Attributes inherited from MethodContext

#calls, #num_statements, #parameters, #refs

Attributes inherited from CodeContext

#name

Instance Method Summary collapse

Methods inherited from MethodContext

#count_statements, #depends_on_instance?, #has_parameter, is_block_arg?, #record_call_to, #record_depends_on_self, #record_instance_variable, #record_local_variable, #record_parameter, #record_use_of_self, #variable_names

Methods inherited from CodeContext

#matches?, #method_missing, #num_methods

Constructor Details

#initialize(outer, exp) ⇒ SingletonMethodContext

Returns a new instance of SingletonMethodContext.



8
9
10
11
12
13
# File 'lib/reek/singleton_method_context.rb', line 8

def initialize(outer, exp)
  super(outer, exp, false)
  @name = Name.new(exp[2])
  @receiver = SexpFormatter.format(exp[1])
  record_depends_on_self
end

Dynamic Method Handling

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

Instance Method Details

#envious_receiversObject



15
16
17
# File 'lib/reek/singleton_method_context.rb', line 15

def envious_receivers
  []
end

#outer_nameObject



19
20
21
# File 'lib/reek/singleton_method_context.rb', line 19

def outer_name
  "#{@outer.outer_name}#{@receiver}.#{@name}/"
end

#to_sObject



23
24
25
# File 'lib/reek/singleton_method_context.rb', line 23

def to_s
  "#{@outer.outer_name}#{@receiver}.#{@name}"
end