В одном из моих проектов у меня есть структура папок:
- Lib
- bar.rb
- бар
- other_bar.rb
- another_bar.rb
- next_bar.rb
- ...
bar.rb
require File.expand_path(File.dirname(__FILE__) + "/bar/other_bar.rb")
class Bar
puts "running BarBase"
end
бар /other _bar.rb
module Bar
class OtherBar
puts "running module Bar with class OtherBar"
end
end
Если теперь я запускаю ruby bar.rb
, я получаю следующее:
работающий модуль Bar с классом OtherBar
bar.rb: 3: in `': Bar не является классом (TypeError)
Я хотел бы иметь аналогичную структуру для структуры наследования модели rails. Как я могу это исправить? Насколько я знаю, рубин не поддерживает это из коробки. Есть ли обходной путь для такой ситуации?