one another. In other words, a class in one box can be inherited by a class in another box. Of course, you can also prepend or include modules in another box. see. Ruby::Box ダイジェスト紹介(Ruby 4.0.0 新機能) - STORES Product Blog 11
class Foo prepend A::BoxA include B::BoxB def foo puts "Main" + Ruby::Box.current.inspect super end end Foo.new.foo # => returns: BoxA#<Ruby::Box:3,user,optional> Main#<Ruby::Box:2,user,main> BoxB#<Ruby::Box:4,user,optional> 13
in the main box. You can evaluate controller and model logic within the child box, And once the controller logic is complete, transparently transfer process to the controller running in the main box. Render views in the main box. Views invoke model method, the logic works on the child box. 15
to apply a patch to zeitwerk we need to override Ruby::Box#require to work automatic module generation. Otherwise, if you run it with RUBY_BOX=1 , it can't load rails components. This issue is related. https://bugs.ruby-lang.org/issues/21830 18
: Box#inspect is confusing. I want to rename it to make it clearer. Ruby::Box#fork : I want to create a box while retaining the LOADED_FEATURE that has already been required in the base box. 22
However, it’s very minimal and very experimental. Still, the way Box works is really interesting!! I can sense its potential!! Let's try to use Ruby::Box and play around with it!! 24