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

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

Overview

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


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

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)

Returns the value of attribute context


87
88
89
# File 'lib/reek/smells/duplicate_method_call.rb', line 87

def context
  @context
end

Instance Method Details

#callsObject


95
96
97
98
99
# File 'lib/reek/smells/duplicate_method_call.rb', line 95

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

#smelly_callsObject


101
102
103
# File 'lib/reek/smells/duplicate_method_call.rb', line 101

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