RubyMine 2020.1 Help

Extract module

The Extract Module refactoring allows you to extract certain members from a selected class into a separate module.

To extract a module:

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

  2. Select Refactor | Extract | Module... on the main menu.

  3. In the Extract Module dialog, specify the module name, a directory where it should be placed, and select members to be added:

    Extract Module dialog

    Click OK. RubyMine will create a module in a separate file.




cat.rb file

class Cat def breathe puts "inhale and exhale" end def speak puts "Meow" end end

cat.rb file

class Cat include Animal def speak puts "Meow" end end
animal.rb file
module Animal def breathe puts "inhale and exhale" end end

Last modified: 29 May 2020