Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 329 Bytes

move-method.md

File metadata and controls

33 lines (24 loc) · 329 Bytes

Move Method

Example

Before

class PaymentCalculator
  def invoice_total
    @invoice.parts.map(&:price).reduce(:+) + @invoice.labor
  end

  # ...
end

After

class PaymentCalculator
  # ...
end

# ...

class Invoice
  def total
    parts.map(&:price).reduce(:+) + labor
  end

  # ...
end