RubyMine 2023.3 Help

Pull members up, push members down

The Pull Members Up refactoring allows you to move class members to a specified superclass. Push Members Down moves class members to a subclass.

Pull members up

To pull members up:

  1. Place a caret at the class name or any place within a class:

    place the caret
  2. Go to Refactor | Pull Members Up....

  3. In the invoked dialog, select the desired members and the superclass where these members will be placed:

    Pull Members Up dialog

    Click OK.

Before

After

cat.rb file

class Cat < Mammal def move puts "move" end def speak puts "Meow" end end

animal.rb file

class Animal def move puts "move" end end

cat.rb file

class Cat < Mammal def speak puts "Meow" end end

Push members down

To push members down:

  1. Place a caret at the class name or any place within a class.

  2. In the main menu, go to Refactor | Push Members Down....

  3. In the invoked dialog, select the desired members that will be moved to a subclass:

    Push Members Down dialog

Click OK.

Before

After

animal.rb file

class Animal def breathe puts "inhale and exhale" end def move puts "move" end end

mammal.rb file

class Mammal < Animal end

animal.rb file

class Animal def move puts "move" end end

mammal.rb file

class Mammal < Animal def breathe puts "inhale and exhale" end end
Last modified: 11 January 2024