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