RubyMine 2017.1 Help

Extract Module

Use the Extract Module refactoring to create a module from the methods and constants of a Ruby class. As a result of this refactoring, methods are extracted into modules, and replaced with the include or extend statements, depending on the selected context.



To extract module from a class

  1. Open the desired class in the editor.
  2. On the main menu, or on the context menu of the editor, choose Refactor | Extract | Module.
  3. In the Extract Module dialog box, provide the following information:
    • Name of the new module.
    • Target directory where it will be stored.
    • Context (instance or static) to form the new module.
    • Methods to be included in the new module. Note that static methods are disabled for the instance context, and vice versa.
  4. Click OK. The new module is created in the specified directory, and the source class is updated accordingly:
    • require statement is added.
    • Extracted code is replaced with the reference to the new module.

See Also

Last modified: 18 July 2017