Class: Reek::Smells::DuplicateMethodCall::CallCollector Private

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/smells/duplicate_method_call.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Collects all calls in a given context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, max_allowed_calls, allow_calls) ⇒ CallCollector

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CallCollector.



91
92
93
94
95
# File 'lib/reek/smells/duplicate_method_call.rb', line 91

def initialize(context, max_allowed_calls, allow_calls)
  @context = context
  @max_allowed_calls = max_allowed_calls
  @allow_calls = allow_calls
end

Instance Attribute Details

#contextObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



89
90
91
# File 'lib/reek/smells/duplicate_method_call.rb', line 89

def context
  @context
end

Instance Method Details

#callsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



97
98
99
100
101
# File 'lib/reek/smells/duplicate_method_call.rb', line 97

def calls
  result = Hash.new { |hash, key| hash[key] = FoundCall.new(key) }
  collect_calls(result)
  result.values.sort_by(&:call)
end

#smelly_callsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



103
104
105
# File 'lib/reek/smells/duplicate_method_call.rb', line 103

def smelly_calls
  calls.select { |found_call| smelly_call? found_call }
end