Method: RuboCop::Cop::HashTransformMethod::Autocorrection#set_new_body_expression

Defined in:
lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb

#set_new_body_expression(transforming_body_expr, corrector) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/rubocop/cop/mixin/hash_transform_method/autocorrection.rb', line 52

def set_new_body_expression(transforming_body_expr, corrector)
  body_source = transforming_body_expr.source
  if transforming_body_expr.hash_type? && !transforming_body_expr.braces?
    body_source = "{ #{body_source} }"
  end

  corrector.replace(block_node.body, body_source)
end