dgsuarez / reruby

Refactor Ruby
MIT License
35 stars 2 forks source link

Extract method in singleton (class << ...) #43

Open dgsuarez opened 5 years ago

dgsuarez commented 5 years ago
class Test
  class << self
    def some_method
      a = 2 * 2
      a * 3
    end
  end
end

extracting the a = 2 * 2 results in

class Test
  class << self
    def some_method
      a = extracted
      a * 3
    end
  end

  def extracted
    2 * 2
  end
end

It should be

class Test
  class << self
    def some_method
      a = extracted
      a * 3
    end

    def extracted
      2 * 2
    end
  end
end