Extract module
Refactor | Extract/Introduce | Module
The Extract Module refactoring allows you to extract certain members from a selected class into a separate module.
To extract a module:
Place a caret at a class name or any place within a class.
Select Refactor | Extract/Introduce | Module from the main menu.
In the Extract Module dialog, specify the module name, a directory where it should be placed, and select members to be added:
Click OK. RubyMine will create a module in a separate file.
Before
# 'cat.rb' fileclass Cat def breathe puts "inhale and exhale" end def speak puts "Meow" endend
After
# 'cat.rb' fileclass Cat include Animal def speak puts "Meow" endend## 'animal.rb' filemodule Animal def breathe puts "inhale and exhale" endend
Thanks for your feedback!
Was this page helpful?