notaceo
notaceo

Reputation: 1093

RubyMine inline refactoring?

Here is some long-form code:

  c.jobs.each do |j|
    j.products.each do |p|
      p.destroy
    end
    j.payments.each do |p|
      p.destroy
    end
    j.destroy
  end

RubyMine has an inline refactoring tool, but it's disabled when I try to refactor any part of this.

I would expect to be able to click on the do by products and inline refactor to:

j.products.each { |p| p.destroy }

In a single keystroke.

What am I doing wrong?

Upvotes: 0

Views: 124

Answers (2)

Aleksey Shein
Aleksey Shein

Reputation: 7482

It seems that you want to change the block form from do ... end to a curly-bracket one { ... }. That's how you do it:

  1. Put your cursor on a do that you want to change.
  2. Type Alt + Enter and select Convert do block to {}
  3. That's it!

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160251

That's not what inlining means.

Inlining means replacing a function invocation with the functionality of that function, e.g.,

def some_fun(x, y)
  x + y
end

z = some_fun(a, b) + c
# Becomes
z = a + b + c

Upvotes: 1

Related Questions