Class: RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
- Inherits:
-
Object
- Object
- RuboCop::Cop::Performance::RedundantMerge::EachWithObjectInspector
- Extended by:
- NodePattern::Macros
- Defined in:
- lib/rubocop/cop/performance/redundant_merge.rb
Overview
A utility class for checking the use of values within an ‘each_with_object` call.
Instance Method Summary collapse
-
#initialize(node, receiver) ⇒ EachWithObjectInspector
constructor
A new instance of EachWithObjectInspector.
- #value_used? ⇒ Boolean
Constructor Details
#initialize(node, receiver) ⇒ EachWithObjectInspector
Returns a new instance of EachWithObjectInspector.
157 158 159 160 |
# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 157 def initialize(node, receiver) @node = node @receiver = unwind(receiver) end |
Instance Method Details
#value_used? ⇒ Boolean
162 163 164 165 166 |
# File 'lib/rubocop/cop/performance/redundant_merge.rb', line 162 def value_used? return false unless eligible_receiver? && second_argument receiver.loc.name.source == second_argument.loc.name.source end |