Reputation: 1093
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
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:
do
that you want to change.Convert do block to {}
Upvotes: 0
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