Suppose I have a few classes defined in a nested module stracture:
Core::UI::Components::TextView
Core::UI::Components::ImageView
Core::UI::Components::Checkbox
Now I have a class that wanna use this classes suppose this class is not inside the 'Core' Module.
class XView
def render
Core::UI::Components::ImageView.new('x').render
Core::UI::Components::TextView.new('x').render
end
end
I want to avoid all the module names writing so I refactor this to
class XView
def render
ui = Core::UI::Components
ui::ImageView.new('x').render
ui::TextView.new('x').render
end
end
Is there a ruby standard for static import of module/class ? how would this be written in the ruby way?
thanks,